This topic is locked

Remove record

4/20/2019 8:29:33 AM
PHPRunner General questions
S
stanbar1 author

Hello i have a problem..i have app employees.every morning they receive job list..i need when they finish (for example 1 job) record remove from list page and move to history table.on edit page i have field 'job is done' when they finish, they press update and after update i need to remove record and they will start new job..Thank you

A
ayctech 4/22/2019

I do not see it complicated, you would have to delete the record and insert in the other table



$sql = "delete from cobros where id_cobros= ".$values['id_cobro'];

CustomQuery($sql);
$sql = "INSERT INTO new_plantel_instructores (id_instituto, id_persona,fecha_insercion) values ($id_instituto, ".$values['id_persona'].",'".$fecha_actual."')";

CustomQuery($sql);
M
Mark Kramer 4/22/2019

Another option it to have a "Completed" integer field with a default of '0" in your table. (I use a check mark for this field.)

Then on your in sql code: for the page.



SELECT



FROM Your Table

WHERE (Completed = 0)*
When they finish, they select the "Completed" check box then save and it will not show up as still being open when listed because the check box saves the numeral "1" to the field in the record.
MK

S
stanbar1 author 4/23/2019



I do not see it complicated, you would have to delete the record and insert in the other table



$sql = "delete from cobros where id_cobros= ".$values['id_cobro'];

CustomQuery($sql);
$sql = "INSERT INTO new_plantel_instructores (id_instituto, id_persona,fecha_insercion) values ($id_instituto, ".$values['id_persona'].",'".$fecha_actual."')";

CustomQuery($sql);



i add this code on event: after update..Nothing happen. maybe i did something wrong, please help me

$sql = "delete from Jobs where id_Jobs= ".$values['id_Jobs'];

CustomQuery($sql);
$sql = "INSERT INTO History (id_Jobs, id_Confirmation,data_insercion) values ($id_Jobs, ".$values['id_Confirmation'].",'".$data_actual."')";

CustomQuery($sql);

S
stanbar1 author 4/23/2019



Another option it to have a "Completed" integer field with a default of '0" in your table. (I use a check mark for this field.)

Then on your in sql code: for the page.



SELECT



FROM Your Table

WHERE (Completed = 0)*
When they finish, they select the "Completed" check box then save and it will not show up as still being open when listed because the check box saves the numeral "1" to the field in the record.
MK



ok but i need this jobs record save on history table, for billing and other..can you please explain me how can i see this record when i need it

M
Mark Kramer 4/25/2019



ok but i need this jobs record save on history table, for billing and other..can you please explain me how can i see this record when i need it


Just create a list page with the WHERE (Completed = 1) to show completed records only.
SELECT

*

FROM Your Table

WHERE (Completed = 1)
Or you could remove the "WHERE" Clause completely and all records will show. In a nut shell , you are filtering your records by the "Completed" field value.

A
ayctech 4/30/2019



i add this code on event: after update..Nothing happen. maybe i did something wrong, please help me

$sql = "delete from Jobs where id_Jobs= ".$values['id_Jobs'];

CustomQuery($sql);
$sql = "INSERT INTO History (id_Jobs, id_Confirmation,data_insercion) values ($id_Jobs, ".$values['id_Confirmation'].",'".$data_actual."')";

CustomQuery($sql);


if you do nothing, your id may be empty, try with $oldvalues ​​['id_Jobs']