guest_line.html

<$RSET.base='"http://www.raz.co.il"'>
<$RPERL.B> # update the db fields if in search or delete mode if('<$RVAR.mod>' eq 'SEARCH' || '<$RVAR.mod>' eq 'DELETE') { print < InitDbFields(); EOM } <$RIF.'"<$RVAR.mod>" eq "DELETE"'> <$RS='DELETE FROM guests WHERE rid=<$RVAR.rid>'> <$REND_IF> <$RIF.'"<$RVAR.mod>" eq "INSERT"'> <$RS='INSERT INTO guests (date,lname,fname,comment,mrktbl_code,intrst_code, note,email,cityname,streetname,housenum,zipcode, phone1,phone2,sid) VALUES ("<$RVAR.date>","<$RVAR.lname>","<$RVAR.fname>", "<$RVAR.comment>","<$RVAR.mrktbl_code_val>", "<$RVAR.intrst_code_val>","<$RVAR.note>","<$RVAR.email>", "<$RVAR.cityname>","<$RVAR.streetname>", "<$RVAR.housenum>","<$RVAR.zipcode>", "<$RVAR.phone1>","<$RVAR.phone2>","<$RVAR.sid>")'> <$REND_IF> <$RIF.'"<$RVAR.mod>" eq "UPDATE"'> <$RS='UPDATE guests SET date="<$RVAR.date>",lname="<$RVAR.lname>", fname="<$RVAR.fname>",comment="<$RVAR.comment>", mrktbl_code="<$RVAR.mrktbl_code_val>", intrst_code="<$RVAR.intrst_code_val>", note="<$RVAR.note>",email="<$RVAR.email>", cityname="<$RVAR.cityname>", streetname="<$RVAR.streetname>", housenum="<$RVAR.housenum>", zipcode="<$RVAR.zipcode>", phone1="<$RVAR.phone1>",phone2="<$RVAR.phone2>" WHERE rid=<$RVAR.rid>'> <$REND_IF> <$RPERL.B> # if updated return to the original search if ('<$RVAR.mod>' eq 'UPDATE') { print < var dt = new Date() -1; window.parent.HEADER.location.href=document.LineForm.location_head.value; location.href=document.LineForm.location_line.value+'&dt='+dt; EOM } <$RPERL.C> # do the currect select my $buf; my $order_by=''; my $i=0; my $n; my @search_where; # holds all the parts of the dynamic range my $search_where=''; # holds the where string my @multi_select; # holds the multi select part of the search where my @multi_select2; # holds the multi select part of the search where my $multi_buf='<$RVAR.mrktbl_code_val>'; # holds the relevent part of the multi string my $multi_buf2='<$RVAR.intrst_code_val>'; # holds the relevent part of the multi string my $step='<$RVAR.step>'; my $limit=(('<$RVAR.start>' ne '' && '<$RVAR.start>' ne ' ')?"limit <$RVAR.start>,$step":"limit 0,$step"); if('<$RVAR.comment>' ne '' && '<$RVAR.comment>' ne ' '){$search_where[$i]='comment LIKE "<$RVAR.comment>"';$i++;} if('<$RVAR.lname>' ne '' && '<$RVAR.lname>' ne ' '){$search_where[$i]='lname LIKE "<$RVAR.lname>"';$i++;} if('<$RVAR.fname>' ne '' && '<$RVAR.fname>' ne ' '){$search_where[$i]='fname LIKE "<$RVAR.fname>"';$i++;} # multi select if('<$RVAR.mrktbl_code_val>' ne '0.0' && '<$RVAR.mrktbl_code_val>' ne '' && '<$RVAR.mrktbl_code_val>' ne ' ') { if(($n=index($multi_buf,'|'))>=0) { $multi_buf=substr($multi_buf,0,$n); } # split the string to an array @multi_select=split(/\,/,$multi_buf); # add sql text to the elements for($n=0;$n<=$#multi_select;$n++) { $multi_select[$n]="mrktbl_code=$multi_select[$n]"; } } # multi select if('<$RVAR.intrst_code_val>' ne '0.0' && '<$RVAR.intrst_code_val>' ne '' && '<$RVAR.intrst_code_val>' ne ' ') { if(($n=index($multi_buf2,'|'))>=0) { $multi_buf2=substr($multi_buf2,0,$n); } # split the string to an array @multi_select2=split(/\,/,$multi_buf2); # add sql text to the elements for($n=0;$n<=$#multi_select2;$n++) { $multi_select2[$n]="intrst_code=$multi_select2[$n]"; } } # create the search where string $search_where=join(' AND ',@search_where); # add the AND stub if there is a statment if($search_where ne ''){$search_where='WHERE '.$search_where;} # create the multi select search where string $multi_buf=join(' OR ',@multi_select); # create the multi select search where string $multi_buf2=join(' OR ',@multi_select2); # add the multi select part to the dynamic search where if($multi_buf ne '') { if($search_where ne '') { $search_where.=' AND ('.$multi_buf.')'; } else { $search_where.='WHERE ('.$multi_buf.')'; } } # add the multi select part to the dynamic search where if($multi_buf2 ne '') { if($search_where ne '') { $search_where.=' AND ('.$multi_buf2.')'; } else { $search_where.='WHERE ('.$multi_buf2.')'; } } if('<$RVAR.order_by>' ne '') { $order_by='ORDER BY <$RVAR.order_by> <$RVAR.order_direction>'; } else { $order_by='ORDER BY a.rid desc'; } # PRE_UPDATE special mode for changing the table before going to update if('<$RVAR.mod>' eq 'PRE_UPDATE') { $buf="RQ=\'SELECT a.*,b.name mrktbl_desc,b.number mrktbl_num,c.name intrst_desc FROM guests a LEFT JOIN tbl b ON a.mrktbl_code=b.code AND b.tbl='MRKTBL' and b.LANGUG_CODE='en' LEFT JOIN tbl c ON a.intrst_code=c.code AND c.tbl='INTRST' and c.LANGUG_CODE='en' WHERE a.rid=<$RVAR.rid>"; } elsif('<$RVAR.mod>' eq 'SEARCH' || '<$RVAR.mod>' eq 'DELETE') { $buf="RQ=\'SELECT a.*,b.name mrktbl_desc,b.number mrktbl_num,c.name intrst_desc FROM guests a LEFT JOIN tbl b ON a.mrktbl_code=b.code AND b.tbl='MRKTBL' and b.LANGUG_CODE='en' LEFT JOIN tbl c ON a.intrst_code=c.code AND c.tbl='INTRST' and c.LANGUG_CODE='en' $search_where $order_by $limit"; } elsif('<$RVAR.mod>' ne 'UPDATE') { $buf="RQ=\'SELECT a.*,b.name mrktbl_desc, b.number mrktbl_num, c.name intrst_desc FROM guests a LEFT JOIN tbl b ON a.mrktbl_code=b.code AND b.tbl='MRKTBL' and b.LANGUG_CODE='en' LEFT JOIN tbl c ON a.intrst_code=c.code AND c.tbl='INTRST' and c.LANGUG_CODE='en' $order_by $limit"; } $buf='<$'.$buf.'\'>'; return $buf; <$RPERL.B> # create the location my $start=0; my $step='<$RVAR.step>'; my $end; if('<$RSQL.rid>' ne '') { if('<$RVAR.start>' ne '') { $start='<$RVAR.start>'; } $end=$start+$step; $start++; print "
Records $start to $end
\n"; } elsif('<$RVAR.mod>' ne 'UPDATE') { print"
End of records
"; }

<$RPERL.B> # print the header if only there are allready lines in table if('<$RSQL.rid>' ne '') { print < Delete | Update | Date | Last name | First name | Areas of interest | Comments | Grade EOM } else { print < EOM } <$RLOOP>
<$REND>

<$RPERL.B> # initilize from here print < Initialize('<$RSQL.rid>'); EOM