[ Pobierz całość w formacie PDF ]
.com )order by customer_idIf you were interested, you could set a cookie to make identifying the user aTipbit easier.PRESENT_DUPS() You need to plan for a couple of eventualities: if there are iden-tical e-mail addresses or phone numbers, but some other personal information haschanged, you need to let the user either update the database or discard the data.This function spots the redundancy and alerts the user.function present_dups ($result){// we have to start the call entry form inside the function -// use a global variable to indicate that this was done.global $in_form;$in_form = 1;// start the formprint start_form( create_call.php );print paragraph( . We may have found you in our database.. Please let us know what you would like to do:. );print start_table();// for each customer record in the result setwhile ($row = mysql_fetch_array($result,MYSQL_ASSOC)){// print out the ID value for the record in a radio field,// allowing the user to choose only one if more than// one is displayed.print table_row( 3537-4 ch13.f.qc 12/15/00 15:25 Page 345Chapter 13: Problem Tracking System 345radio_field( customer_id, $row[ customer_id ],  Use this row),  Record #.$row[ customer_id ]. );// print out the name & address information from this recordprint table_row(  ,$row[ firstname ]. .$row[ lastname ]);if (!empty($row[ address ])){print table_row(  ,$row[ address ]);}if (!empty($row[ address2 ])){print table_row(  ,$row[ address2 ]);}if ( !empty($row[ city ]) || !empty($row[ state ])|| !empty($row[ zip ])){print table_row( , $row[ city ]. , .$row[ state ]. .$row[ zip ]);}if (!empty($row[ day_prefix ])){$daycell =  Day: .$row[ day_area ]. .$row[ day_prefix ]. -.$row[ day_suffix ];if (!empty($row[ day_ext ])){$daycell.=  .$row[ day_ext ];}if (!empty($row[ day_start ])){ 3537-4 ch13.f.qc 12/15/00 15:25 Page 346346 Part IV: Not So Simple Applications$daycell.=  from .$row[ day_start ];}if (!empty($row[ day_end ])){$daycell.=  until .$row[ day_end ];}print table_row(  ,$daycell);}if (!empty($row[ eve_prefix ])){$evecell =  Eve: .$row[ eve_area ]. .$row[ eve_prefix ]. -.$row[ eve_suffix ];if (!empty($row[ eve_ext ])){$evecell.=  .$row[ eve_ext ];}if (!empty($row[ eve_start ])){$evecell.=  from .$row[ eve_start ];}if (!empty($row[ eve_end ])){$evecell.=  until .$row[ eve_end ];}print table_row(  ,$evecell);}if (!empty($row[ email ])){print table_row(  ,$row[ email ]);}// print out a checkbox field allowing the user to// indicate that this record should be overwritten// with the information from the form.print table_row( , checkbox_field( override 3537-4 ch13.f.qc 12/15/00 15:25 Page 347Chapter 13: Problem Tracking System 347, $row[ customer_id ],  Override this entry with the new. information in the form below.));// print out a checkbox field allowing the user to// indicate that this record should be merged// with the information from the form and the result// written back to the database.print table_row( , checkbox_field( merge, $row[ customer_id ],  Merge this entry with the new. information in the form below.));}print end_table();// print out a final radio field indicating that, rather than// using any of the records found in the database, a new record// should be created.print paragraph(radio_field( add_as_new,  yes,  Create a new record with the information in the formbelow.));}All the duplicate rows are printed, and the user can choose what to do with thedata.You can see this in action if you go to the index.php page of this applicationand attempt to enter two different tickets with, say, the same phone number.Figure13-6 gives an example. 3537-4 ch13.f.qc 12/15/00 15:25 Page 348348 Part IV: Not So Simple ApplicationsFigure 13-6: Form for updating customer informationHISTORY_ENTRY() When a staff member enters an update on a problem, the stepis stored in the history table.If the entry is  public the user will be e-mailed withthe update; if not, there will be no e-mail.Notice the interesting query.Here the insert contains a select statement.The onlything this select is actually getting is the source_id related to the variable $source.All the rest of the insert information comes from variables.function history_entry($problem_id=  ,$entry_type_id=  ,$entered_by= ,$source=  ,$notes= ){if (empty($problem_id)) { return FALSE; }if (empty($entered_by)) { $entered_by =  customer ; }// create a record in the history table, getting the ID value// of the source from the sources table.$query =  insert into history(problem_id,entry_type_id,entered_by,source_id,notes)select  $problem _id,$entry_type_id, $entered_by , 3537-4 ch13.f [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • wpserwis.htw.pl