dave_biscuits Posted June 3, 2008 Share Posted June 3, 2008 I'm scratching my head at the moment ... for simplified purposes, I have a complicated script that pretty much goes along the lines of: for ( $counter = 1; $counter <= 100; $counter += 1) { $message = $message."<TABLE><TR><TD> ... </TD></TR></TABLE>"; } echo "document.getElementById('results').innerHTML = '".$message."';"; now that takes ~30 seconds for the machine to crunch and display ... during this time, httpd goes CPU crazy. now, if i do this in a 'javascript' solution ... ie ... for ( $counter = 1; $counter <= 100; $counter += 1) { echo "document.getElementById('results').innerHTML = document.getElementById('results').innerHTML."<TABLE><TR><TD> ... </TD></TR></TABLE>"; } then the whole thing takes ~5 seconds ... WHY ???? (more importantly, why is PHP so inefficient in storing text in variables??) Cheers, Dave. Quote Link to comment https://forums.phpfreaks.com/topic/108478-big-variable-high-cpu-why/ Share on other sites More sharing options...
dsaba Posted June 3, 2008 Share Posted June 3, 2008 Well its not just pure plaintext being echoed by PHP, as you see here: echo "document.getElementById('results').innerHTML = '".$message."';"; I think your browser is doing work trying to resolve the javascript, once it is done then it allows php to continue processing.. which makes the whole process much slower. I know that getElementByID() function in javascript is particularly slow if it has to dig through a lot of html on the page or a lot "elements". Run some kind of test to prove or disprove my theory. Quote Link to comment https://forums.phpfreaks.com/topic/108478-big-variable-high-cpu-why/#findComment-556213 Share on other sites More sharing options...
kenrbnsn Posted June 3, 2008 Share Posted June 3, 2008 What are you talking about: I think your browser is doing work trying to resolve the javascript, once it is done then it allows php to continue processing.. which makes the whole process much slower. I know that getElementByID() function in javascript is particularly slow if it has to dig through a lot of html on the page or a lot "elements". The browser doesn't see the generated Javascript until after PHP is finished creating it. If the OP does a "show source" on the generated Javascript, he will see a very long string generated. If he takes that generates string and puts it into his Javascript source, he will probably see the same performance hit. Ken Quote Link to comment https://forums.phpfreaks.com/topic/108478-big-variable-high-cpu-why/#findComment-556223 Share on other sites More sharing options...
dsaba Posted June 3, 2008 Share Posted June 3, 2008 What are you talking about: - There's a nice way to say you think I'm wrong. Woops, I thought his loop was echoing each piece of javascript 1 at a time. Quote Link to comment https://forums.phpfreaks.com/topic/108478-big-variable-high-cpu-why/#findComment-556226 Share on other sites More sharing options...
kenrbnsn Posted June 3, 2008 Share Posted June 3, 2008 It doesn't matter whether the PHP echoes one line at a time or all the lines at once, the browser won't see them until after PHP exits. Ken Quote Link to comment https://forums.phpfreaks.com/topic/108478-big-variable-high-cpu-why/#findComment-556229 Share on other sites More sharing options...
corbin Posted June 3, 2008 Share Posted June 3, 2008 Unless the buffer is purposely flushed, but buffering was never mentioned so.... Anyway, on my local machine, php can handle this script fine... With Apache Benchmark, I made 50 requests to the page (because I was too lazy to just store/subtract a timestamp), and it made the 50 requests in under .2 seconds. Which process is it that is taking so much CPU? PHP or the browser? Quote Link to comment https://forums.phpfreaks.com/topic/108478-big-variable-high-cpu-why/#findComment-556230 Share on other sites More sharing options...
dsaba Posted June 3, 2008 Share Posted June 3, 2008 hey whad up during this time, httpd goes CPU crazy. Well looks like apache... Not all CPUS are created alike though. Quote Link to comment https://forums.phpfreaks.com/topic/108478-big-variable-high-cpu-why/#findComment-556231 Share on other sites More sharing options...
awpti Posted June 3, 2008 Share Posted June 3, 2008 On a side note.. <?php for ( $counter = 1; $counter <= 100; $counter += 1) Should be: <?php for ( $counter = 1; $counter <= 100; ++$counter) Wouldn't be surprised if that was hurting you a bit. 30 seconds? No way. Your browser is jacked or your setup is very VERY VERY poorly configured. [20:44] [root@geeklan : httpdocs]# time php test.php /* SNIP */ real 0m0.028s user 0m0.022s sys 0m0.006s Quote Link to comment https://forums.phpfreaks.com/topic/108478-big-variable-high-cpu-why/#findComment-556232 Share on other sites More sharing options...
corbin Posted June 3, 2008 Share Posted June 3, 2008 Ahhh sorry.... Didn't read that I guess lol... So it is PHP (well... probably PHP unless something else could be influencing Apache). Hrmmm to the OP, will you post the entire script? This alone shouldn't be CPU intensive. (To expand on awpti's post, this is the code I used: <?php $message = ''; for($i = 0; $i < 100; ++$i) { $message .= "<TABLE><TR><TD> ... </TD></TR></TABLE>"; } echo "document.getElementById('results').innerHTML = '".$message."';"; figured it wouldn't be much faster than your's, but I guess it could be.... testing your's now. ) Edit: OP's code is .05 seconds slower for 50 requests. Quote Link to comment https://forums.phpfreaks.com/topic/108478-big-variable-high-cpu-why/#findComment-556234 Share on other sites More sharing options...
dsaba Posted June 3, 2008 Share Posted June 3, 2008 It doesn't matter whether the PHP echoes one line at a time or all the lines at once, the browser won't see them until after PHP exits. Ken Then why does an endless loop cause my browser to freeze up? Technically, PHP would never be done. Quote Link to comment https://forums.phpfreaks.com/topic/108478-big-variable-high-cpu-why/#findComment-556238 Share on other sites More sharing options...
corbin Posted June 3, 2008 Share Posted June 3, 2008 It doesn't matter whether the PHP echoes one line at a time or all the lines at once, the browser won't see them until after PHP exits. Ken Then why does an endless loop cause my browser to freeze up? Technically, PHP would never be done. http://us2.php.net/outcontrol Quote Link to comment https://forums.phpfreaks.com/topic/108478-big-variable-high-cpu-why/#findComment-556242 Share on other sites More sharing options...
Daniel0 Posted June 3, 2008 Share Posted June 3, 2008 On a side note.. <?php for ( $counter = 1; $counter <= 100; $counter += 1) Should be: <?php for ( $counter = 1; $counter <= 100; ++$counter) That's exactly the same... Quote Link to comment https://forums.phpfreaks.com/topic/108478-big-variable-high-cpu-why/#findComment-556259 Share on other sites More sharing options...
Barand Posted June 3, 2008 Share Posted June 3, 2008 Over 100,000 iterations I found the latter to be a millisecond faster <?php $k = 100000; $t1 = microtime(1); for ($i=0; $i < $k; $i += 1); $t2 = microtime(1); for ($i=0; $i < $k; ++$i); $t3 = microtime(1); printf ('A: %0.6f<br>B: %0.6f', $t2 - $t1, $t3 - $t2); ?> --> A: 0.034869 B: 0.033557 Quote Link to comment https://forums.phpfreaks.com/topic/108478-big-variable-high-cpu-why/#findComment-556274 Share on other sites More sharing options...
dave_biscuits Posted June 3, 2008 Author Share Posted June 3, 2008 Hmm ok ... I think everyone took me too literally here ... like i said, its more complicated than the snippet of code i drummed up for the example ... what i was trying to explain is that the script i posted was only a sample (eg concept) of what I was doing ... AJAX calls a php file to refresh the contents of a certain table in my HTML application ... Definitely not the browser chugging, have watched top (FreeBSD) and when PHP is storing the table contents to echo at the end of the loop (as opposed to echoing text at the end of every iteration), its httpd thats busy for 30 secs or so ... I tried posting the code ... but it exceeds the 40,000 character limit apparently ... anyway, just trust me on this one ... the size of the table returned by AJAX is ~ 1MB+ ... browser only takes 2-3 seconds to parse it tho once PHP passes it on in either senario ... Cheers, Dave. Quote Link to comment https://forums.phpfreaks.com/topic/108478-big-variable-high-cpu-why/#findComment-556278 Share on other sites More sharing options...
dave_biscuits Posted June 3, 2008 Author Share Posted June 3, 2008 One thing I did think it might be was PHP's memory limit ... possibly running out of memory while storing up that 1MB+ data for javascript in a variable ... maybe chugging due to low resource limits or something ... but server has plenty of ram, and php.ini was set generously ... ;;;;;;;;;;;;;;;;;;; ; Resource Limits ; ;;;;;;;;;;;;;;;;;;; max_execution_time = 130 ; Maximum execution time of each script, in seconds max_input_time = 60 ; Maximum amount of time each script may spend parsing request data memory_limit = 150M ; Maximum amount of memory a script may consume (8MB) Cheers, Dave. Quote Link to comment https://forums.phpfreaks.com/topic/108478-big-variable-high-cpu-why/#findComment-556281 Share on other sites More sharing options...
Wolphie Posted June 3, 2008 Share Posted June 3, 2008 AJAX can cause extremely high CPU usage if it's poorly implemented and if there's a lot of HTTP requests being made, post your AJAX code. I'd also check your CPU usage for the browser, apache and the database while running your script to be sure which is causing the problem. Also, what OS are you running, version of PHP, apache etc.. there could be a known issue somewhere. Not only that, but a script which is 40,000 characters long is a bit of a stretch. This could also be your problem, try running only the code you posted and it's dependencies in a script by it's self and see what happens. Quote Link to comment https://forums.phpfreaks.com/topic/108478-big-variable-high-cpu-why/#findComment-556282 Share on other sites More sharing options...
dave_biscuits Posted June 3, 2008 Author Share Posted June 3, 2008 Ok, I'll have another go at posting this code ... Basically, you hit the "refresh" button on the HTML application, one AJAX call is made ($_POST['method']=='refresh_allocate2-ORIGINAL' used to activate this particular function). so, FIRST version: grubby code - store all javascript data in PHP variables, echo at end of script ... if($_POST['method']=='refresh_allocate2-ORIGINAL') { $time_start = microtime_float(); $allocate_a = ''; $allocate_w = ''; $allocate_j = ''; $allocate_all = ''; $allocate_a_tag = '1'; $allocate_w_tag = '1'; $allocate_j_tag = '1'; $allocate_all_tag = '1'; if($special=='') { $special2 = " WHERE credit_status = 'issued' AND credit_amount <> credit_paid "; } else { $special2 = $special." AND credit_status = 'issued' AND credit_amount <> credit_paid "; } $results = ''; $query = "SELECT credits.*, customer.* from credits left outer join customer on (credits.credit_customer = customer.customer_no) ".$special2." order by credit_uid::integer DESC, credit_created::integer DESC; ;"; //echo "prompt('',unescape('".rawurlencode($query)."'));"; $query = pg_query($query); while($row = pg_fetch_array($query,NULL,PGSQL_ASSOC)) { $nome = ''; if($row['customer_surname']!='') { $nome = $row['customer_surname'].", ".$row['customer_firstname']; } else { $nome = $row['customer_name']; } if($row['customer_company']!='') { if($nome=='') { $nome = $row['customer_company']; } else { $nome = $nome." (".$row['customer_company'].")"; } } $row['nome'] = $nome; $results[] = $row; $last_cust = $row; } $credit_results = $results; if($special3=='') { $special3 = " WHERE bank_temporary.status = 'actual' AND bank_temporary.amount != '0' "; } $results = ''; $query = "SELECT bank_temporary.*, customer.* from bank_temporary left outer join customer on (bank_temporary.customer_uid = customer.customer_no) ".$special3." order by bank_uid::integer DESC, created::integer DESC; "; //echo "prompt('',unescape('".rawurlencode($query)."'));"; $query = pg_query($query); while($row = pg_fetch_array($query,NULL,PGSQL_ASSOC)) { $nome = ''; if($row['customer_surname']!='') { $nome = $row['customer_surname'].", ".$row['customer_firstname']; } else { $nome = $row['customer_name']; } if($row['customer_company']!='') { if($nome=='') { $nome = $row['customer_company']; } else { $nome = $nome." (".$row['customer_company'].")"; } } $row['nome'] = $nome; $results[] = $row; $last_cust = $row; } if($special!='') { echo "try { document.getElementById('allo_select_cust').innerHTML = \"<FONT STYLE='color: #009900;'><B>\"+unescape('".rawurlencode($last_cust['nome'])."')+\"</B></FONT>\"; } catch(e) { }"; if($last_cust['nome']=='') { echo "try { document.getElementById('allo_select_cust').innerHTML = \"<FONT STYLE='color: #990000;'><I>\"+unescape('".rawurlencode('No bankings under this customer.')."')+\"</I></FONT>\"; } catch(e) { }"; } } foreach ($results as $result) { if($result['customer_uid']=='') { if($allocate_w_tag == "1") { $colour = "D6CFAD"; /* Dark */ } else { $colour = "EDE7CB"; /* Light */ } $allocate_w_tag = $allocate_w_tag*-1; //if($results['nome']=='') { $results['nome'] = '?'; } $allocate_w = $allocate_w." <TR STYLE='background:#".$colour."; height: 22px; cursor: hand;' onMouseOver=\"colorMe(document.getElementById('allocate_w_".$result['bank_uid']."'),'".$colour."');\" onMouseOut=\"plainJane(document.getElementById('allocate_w_".$result['bank_uid']."'),'".$colour."');\" ID='allocate_w_".$result['bank_uid']."' COLOR_NOW='".$colour."' COLOR_RESTORE='".$colour."' BASTARD_AMOUNT='".$result['amount']."' BASTARD_COMMENTS='".$result['bank_comments']."'> <TD onClick=\"nailThis(document.getElementById('allocate_w_".$result['bank_uid']."'),'".$colour."');\"> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0'> <TR> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD>".method_square($result['method'], $result['bank_uid'],'right')."</TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 50px;'><SPAN STYLE=' color: #333333;'>P".$result['bank_uid']."</SPAN></DIV></TD> <TD><TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='color: #FFFFFF;'><TR><TD><IMG SRC='shim.gif' WIDTH='4' HEIGHT='1'></TD><TD><IMG SRC='rain_w.png'></TD></TR></TABLE></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 40px;'><SPAN STYLE=' color: #333333;'>".date('d M',$result['created'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 150px;'><SPAN STYLE=' color: #333333;'>".$result['nome']."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 55px;'><SPAN STYLE=' color: #333333;'>$".$result['amount']."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 144px;'><SPAN STYLE=' color: #333333;'>".rawurldecode($result['bank_comments'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> </TR> </TABLE> </TD> <TD> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='position: relative; top: 1px;'><TR><TD><DIV ID='w_allo_noter".$result['bank_uid']."' STYLE='width: 13px; height: 13px; background: "; if($result['bank_notes']!='') { $note_on = 'yes'; } else { $note_on = 'no'; } if($note_on=='yes') { $allocate_w = $allocate_w."#0066CC; border: solid 1px #0066CC; "; } else { $allocate_w = $allocate_w."#94B7D1; border: solid 1px #6698BD; "; } $allocate_w = $allocate_w." color: #FFFFFF; font-size: 9px; cursor: hand;'><SPAN onClick=\"loadNote('".$result['bank_uid']."');\"><CENTER>N</CENTER></SPAN></DIV></TD></TR></TABLE> </TD> <TD><IMG SRC='shim.gif' WIDTH='8' HEIGHT='1'></TD> <TD><IMG SRC='kharcross.gif' STYLE='position: relative; top: 1px;' onClick=\"deleteBankUID('".$result['bank_uid']."');\" ></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> </TR> "; // START ALL ************* // START ALL ************* // START ALL ************* if($allocate_all_tag == "1") { $colour = "D6CFAD"; //Dark Grey } if($allocate_all_tag == "-1") { $colour = "EDE7CB"; //Light Grey } $allocate_all_tag = $allocate_all_tag*-1; $allocate_all = $allocate_all." <FONT ID='nailer".$result['bank_uid']."' CUSTOMERUID='".$result['customer_uid']."'></FONT> <TR STYLE='background:#".$colour."; height: 22px; cursor: hand;' onMouseOver=\"colorMe(this,'".$colour."');\" onMouseOut=\"plainJane(this,'".$colour."');\" ID='allocate_all_".$result['bank_uid']."' COLOR_NOW='".$colour."' COLOR_RESTORE='".$colour."' BASTARD_AMOUNT='".$result['amount']."' BASTARD_COMMENTS='".$result['bank_comments']."'> <TD onClick=\"nailThis(document.getElementById('allocate_all_".$result['bank_uid']."'),'".$colour."');\"> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' ID='check_customer".$result['bank_uid']."' CUSTOMER='".$result['customer_uid']."'> <TR> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD>".method_square($result['method'], $result['bank_uid'],'right')."</TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 50px;'><SPAN STYLE=' color: #333333;'>P".$result['bank_uid']."</SPAN></DIV></TD> <TD><TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='color: #FFFFFF;'><TR><TD><IMG SRC='shim.gif' WIDTH='4' HEIGHT='1'></TD><TD><IMG SRC='rain_w.png'></TD></TR></TABLE></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 40px;'><SPAN STYLE=' color: #333333;'>".date('d M',$result['created'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 150px;'><SPAN STYLE=' color: #333333;'>".$result['nome']."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 55px;'><SPAN STYLE=' color: #333333;'>$".$result['amount']."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 144px;'><SPAN STYLE=' color: #333333;'>".rawurldecode($result['bank_comments'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> </TR> </TABLE> </TD> <TD> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='position: relative; top: 1px;'><TR><TD><DIV ID='all_allo_noter".$result['bank_uid']."' STYLE='width: 13px; height: 13px; background: "; if($result['bank_notes']!='') { $note_on = 'yes'; } else { $note_on = 'no'; } if($note_on=='yes') { $allocate_all = $allocate_all."#0066CC; border: solid 1px #0066CC; "; } else { $allocate_all = $allocate_all."#94B7D1; border: solid 1px #6698BD; "; } $allocate_all = $allocate_all." color: #FFFFFF; font-size: 9px; cursor: hand;'><SPAN onClick=\"loadNote('".$result['bank_uid']."');\"><CENTER>N</CENTER></SPAN></DIV></TD></TR></TABLE> </TD> <TD><IMG SRC='shim.gif' WIDTH='8' HEIGHT='1'></TD> <TD><IMG SRC='kharcross.gif' STYLE='position: relative; top: 1px;' onClick=\"deleteBankUID('".$result['bank_uid']."');\" ></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> </TR> "; // END ALL ************* // END ALL ************* // END ALL ************* } else { if($result['bank_category']=='banking') { if($allocate_a_tag == "1") { $colour = "D6CFAD"; //Dark Grey } if($allocate_a_tag == "-1") { $colour = "EDE7CB"; //Light Grey } $allocate_a_tag = $allocate_a_tag*-1; $allocate_a = $allocate_a." <TR STYLE='background:#".$colour."; height: 22px; cursor: hand;' onMouseOver=\"colorMe(this,'".$colour."');\" onMouseOut=\"plainJane(this,'".$colour."');\" ID='allocate_a_".$result['bank_uid']."' COLOR_NOW='".$colour."' COLOR_RESTORE='".$colour."' BASTARD_AMOUNT='".$result['amount']."' BASTARD_COMMENTS='".$result['bank_comments']."'> <TD onClick=\"nailThis(document.getElementById('allocate_a_".$result['bank_uid']."'),'".$colour."');\"> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0'> <TR> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD>".method_square($result['method'], $result['bank_uid'],'right')."</TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 50px;'><SPAN STYLE=' color: #333333;'>P".$result['bank_uid']."</SPAN></DIV></TD> <TD><TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='color: #FFFFFF;'><TR><TD><IMG SRC='shim.gif' WIDTH='4' HEIGHT='1'></TD><TD><IMG SRC='rain_a.png'></TD></TR></TABLE></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 40px;'><SPAN STYLE=' color: #333333;'>".date('d M',$result['created'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 150px;'><SPAN STYLE=' color: #333333;'>".$result['nome']."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 55px;'><SPAN STYLE=' color: #333333;'>$".$result['amount']."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 144px;'><SPAN STYLE=' color: #333333;'>".rawurldecode($result['bank_comments'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> </TR> </TABLE> </TD> <TD> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='position: relative; top: 1px;'><TR><TD><DIV ID='a_allo_noter".$result['bank_uid']."' STYLE='width: 13px; height: 13px; background: "; if($result['bank_notes']!='') { $note_on = 'yes'; } else { $note_on = 'no'; } if($note_on=='yes') { $allocate_a = $allocate_a."#0066CC; border: solid 1px #0066CC; "; } else { $allocate_a = $allocate_a."#94B7D1; border: solid 1px #6698BD; "; } $allocate_a = $allocate_a." color: #FFFFFF; font-size: 9px; cursor: hand;'><SPAN onClick=\"loadNote('".$result['bank_uid']."');\"><CENTER>N</CENTER></SPAN></DIV></TD></TR></TABLE> </TD> <TD><IMG SRC='shim.gif' WIDTH='8' HEIGHT='1'></TD> <TD><IMG SRC='kharcross.gif' STYLE='position: relative; top: 1px;' onClick=\"deleteBankUID('".$result['bank_uid']."');\" ></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> </TR> "; // START ALL ************* // START ALL ************* // START ALL ************* if($allocate_all_tag == "1") { $colour = "D6CFAD"; //Dark Grey } if($allocate_all_tag == "-1") { $colour = "EDE7CB"; //Light Grey } $allocate_all_tag = $allocate_all_tag*-1; $allocate_all = $allocate_all." <FONT ID='nailer".$result['bank_uid']."' CUSTOMERUID='".$result['customer_uid']."'></FONT> <TR STYLE='background:#".$colour."; height: 22px; cursor: hand;' onMouseOver=\"colorMe(this,'".$colour."');\" onMouseOut=\"plainJane(this,'".$colour."');\" ID='allocate_all_".$result['bank_uid']."' COLOR_NOW='".$colour."' COLOR_RESTORE='".$colour."' BASTARD_AMOUNT='".$result['amount']."' BASTARD_COMMENTS='".$result['bank_comments']."'> <TD onClick=\"nailThis(document.getElementById('allocate_all_".$result['bank_uid']."'),'".$colour."');\"> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' ID='check_customer".$result['bank_uid']."' CUSTOMER='".$result['customer_uid']."'> <TR> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD>".method_square($result['method'], $result['bank_uid'],'right')."</TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 50px;'><SPAN STYLE=' color: #333333;'>P".$result['bank_uid']."</SPAN></DIV></TD> <TD><TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='color: #FFFFFF;'><TR><TD><IMG SRC='shim.gif' WIDTH='4' HEIGHT='1'></TD><TD><IMG SRC='rain_a.png'></TD></TR></TABLE></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 40px;'><SPAN STYLE=' color: #333333;'>".date('d M',$result['created'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 150px;'><SPAN STYLE=' color: #333333;'>".$result['nome']."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 55px;'><SPAN STYLE=' color: #333333;'>$".$result['amount']."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 144px;'><SPAN STYLE=' color: #333333;'>".rawurldecode($result['bank_comments'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> </TR> </TABLE> </TD> <TD> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='position: relative; top: 1px;'><TR><TD><DIV ID='all_allo_noter".$result['bank_uid']."' STYLE='width: 13px; height: 13px; background: "; if($result['bank_notes']!='') { $note_on = 'yes'; } else { $note_on = 'no'; } if($note_on=='yes') { $allocate_all = $allocate_all."#0066CC; border: solid 1px #0066CC; "; } else { $allocate_all = $allocate_all."#94B7D1; border: solid 1px #6698BD; "; } $allocate_all = $allocate_all." color: #FFFFFF; font-size: 9px; cursor: hand;'><SPAN onClick=\"loadNote('".$result['bank_uid']."');\"><CENTER>N</CENTER></SPAN></DIV></TD></TR></TABLE> </TD> <TD><IMG SRC='shim.gif' WIDTH='8' HEIGHT='1'></TD> <TD><IMG SRC='kharcross.gif' STYLE='position: relative; top: 1px;' onClick=\"deleteBankUID('".$result['bank_uid']."');\" ></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> </TR> "; // END ALL ************* // END ALL ************* // END ALL ************* } else { if($allocate_j_tag == "1") { $colour = "D6CFAD"; //Dark Grey } if($allocate_j_tag == "-1") { $colour = "EDE7CB"; //Light Grey } $allocate_j_tag = $allocate_j_tag*-1; $allocate_j = $allocate_j." <TR STYLE='background:#".$colour."; height: 22px; cursor: hand;' onMouseOver=\"colorMe(this,'".$colour."');\" onMouseOut=\"plainJane(this,'".$colour."');\" ID='allocate_j_".$result['bank_uid']."' COLOR_NOW='".$colour."' COLOR_RESTORE='".$colour."' BASTARD_AMOUNT='".$result['amount']."' BASTARD_COMMENTS='".$result['bank_comments']."'> <TD onClick=\"nailThis(document.getElementById('allocate_j_".$result['bank_uid']."'),'".$colour."');\"> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0'> <TR> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD>".method_square($result['method'], $result['bank_uid'],'right')."</TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 50px;'><SPAN STYLE=' color: #333333;'>P".$result['bank_uid']."</SPAN></DIV></TD> <TD><TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='color: #FFFFFF;'><TR><TD><IMG SRC='shim.gif' WIDTH='4' HEIGHT='1'></TD><TD><IMG SRC='rain_j.png'></TD></TR></TABLE></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 40px;'><SPAN STYLE=' color: #333333;'>".date('d M',$result['created'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 150px;'><SPAN STYLE=' color: #333333;'>".$result['nome']."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 55px;'><SPAN STYLE=' color: #333333;'>$".$result['amount']."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 144px;'><SPAN STYLE=' color: #333333;'>".rawurldecode($result['bank_comments'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> </TR> </TABLE> </TD> <TD> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='position: relative; top: 1px;'><TR><TD><DIV ID='j_allo_noter".$result['bank_uid']."' STYLE='width: 13px; height: 13px; background: "; if($result['bank_notes']!='') { $note_on = 'yes'; } else { $note_on = 'no'; } if($note_on=='yes') { $allocate_j = $allocate_j."#0066CC; border: solid 1px #0066CC; "; } else { $allocate_j = $allocate_j."#94B7D1; border: solid 1px #6698BD; "; } $allocate_j = $allocate_j." color: #FFFFFF; font-size: 9px; cursor: hand;'><SPAN onClick=\"loadNote('".$result['bank_uid']."');\"><CENTER>N</CENTER></SPAN></DIV></TD></TR></TABLE> </TD> <TD><IMG SRC='shim.gif' WIDTH='8' HEIGHT='1'></TD> <TD><IMG SRC='kharcross.gif' STYLE='position: relative; top: 1px;' onClick=\"deleteBankUID('".$result['bank_uid']."');\" ></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> </TR> "; // START ALL ************* // START ALL ************* // START ALL ************* if($allocate_all_tag == "1") { $colour = "D6CFAD"; //Dark Grey } if($allocate_all_tag == "-1") { $colour = "EDE7CB"; //Light Grey } $allocate_all_tag = $allocate_all_tag*-1; $allocate_all = $allocate_all." <FONT ID='nailer".$result['bank_uid']."' CUSTOMERUID='".$result['customer_uid']."'></FONT> <TR STYLE='background:#".$colour."; height: 22px; cursor: hand;' onMouseOver=\"colorMe(this,'".$colour."');\" onMouseOut=\"plainJane(this,'".$colour."');\" ID='allocate_all_".$result['bank_uid']."' COLOR_NOW='".$colour."' COLOR_RESTORE='".$colour."' BASTARD_AMOUNT='".$result['amount']."' BASTARD_COMMENTS='".$result['bank_comments']."'> <TD onClick=\"nailThis(document.getElementById('allocate_all_".$result['bank_uid']."'),'".$colour."');\"> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' ID='check_customer".$result['bank_uid']."' CUSTOMER='".$result['customer_uid']."'> <TR> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD>".method_square($result['method'], $result['bank_uid'],'right')."</TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 50px;'><SPAN STYLE=' color: #333333;'>P".$result['bank_uid']."</SPAN></DIV></TD> <TD><TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='color: #FFFFFF;'><TR><TD><IMG SRC='shim.gif' WIDTH='4' HEIGHT='1'></TD><TD><IMG SRC='rain_j.png'></TD></TR></TABLE></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 40px;'><SPAN STYLE=' color: #333333;'>".date('d M',$result['created'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 150px;'><SPAN STYLE=' color: #333333;'>".$result['nome']."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 55px;'><SPAN STYLE=' color: #333333;'>$".$result['amount']."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 144px;'><SPAN STYLE=' color: #333333;'>".rawurldecode($result['bank_comments'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> </TR> </TABLE> </TD> <TD> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='position: relative; top: 1px;'><TR><TD><DIV ID='all_allo_noter".$result['bank_uid']."' STYLE='width: 13px; height: 13px; background: "; if($result['bank_notes']!='') { $note_on = 'yes'; } else { $note_on = 'no'; } if($note_on=='yes') { $allocate_all = $allocate_all."#0066CC; border: solid 1px #0066CC; "; } else { $allocate_all = $allocate_all."#94B7D1; border: solid 1px #6698BD; "; } $allocate_all = $allocate_all." color: #FFFFFF; font-size: 9px; cursor: hand;'><SPAN onClick=\"loadNote('".$result['bank_uid']."');\"><CENTER>N</CENTER></SPAN></DIV></TD></TR></TABLE> </TD> <TD><IMG SRC='shim.gif' WIDTH='8' HEIGHT='1'></TD> <TD><IMG SRC='kharcross.gif' STYLE='position: relative; top: 1px;' onClick=\"deleteBankUID('".$result['bank_uid']."');\" ></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> </TR> "; // END ALL ************* // END ALL ************* // END ALL ************* } } } // end foreach results foreach ($credit_results as $result) { // ADD IN MODULE FOR CREDIT NOTES ******************************************** START // ADD IN MODULE FOR CREDIT NOTES ******************************************** START // ADD IN MODULE FOR CREDIT NOTES ******************************************** START if($allocate_c_tag == "1") { $colour = "D6CFAD"; //Dark Grey } if($allocate_c_tag == "-1") { $colour = "EDE7CB"; //Light Grey } $allocate_c_tag = $allocate_c_tag*-1; //autoCred('".$row['credit_uid']."'); $temp = str_replace('%5E','',$result['credit_refinv']); $insert = ''; $insert2 = ''; $insert3 = ''; if(trim($temp)!='') { $insert = ""; $apply_data = ''; $apply_data = explode('^^',rawurldecode($result['credit_refinv'])); $precheck = ''; $ddata = ''; $supercounter = '0'; $mesSsage = ''; foreach ($apply_data as $ddata) { if($supercounter=='2') { $supercounter = '0'; if($failrate=='n') { $apply_counter++; $failrate = ''; } } if($supercounter=='0') { $precheck = $ddata; $supercounter++; continue; } if($supercounter=='1') { if((trim($precheck)!='') || (trim($ddata)!='')) { if($precheck=='') { $mesSsage = $mesSsage."<I>Job Unknown</I> "; } else { $mesSsage = $mesSsage.$precheck." "; } if($ddata!='') { $mesSsage = $mesSsage."($".$ddata.")"; } $mesSsage = $mesSsage."<IMG SRC='shim.gif' WIDTH='10' HEIGHT='1'>"; $failrate = 'n'; } $supercounter++; continue; } } //$mesSsage = 'blah'; if($mesSsage!='') { $mesSsage = "<DIV STYLE='width: 240px;'><SPAN STYLE=''><TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='color: #333333;'><TR><TD>".$mesSsage."</TD></TR></TABLE></SPAN></DIV>"; $insert2 = "<FONT STYLE='color: #CC0000; cursor: help;' onMouseOver=\"smith('second', unescape('".rawurlencode($mesSsage)."')); document.all['smith'].style.display = 'block'; this.onmousemove = getMouseXY3;\" onMouseOut=\"document.all['smith'].style.display = 'none';\">"; $insert3 = "</FONT>"; } } else { $insert = "visibility: hidden;"; } $allocate_c = $allocate_c." <TR STYLE='background:#".$colour."; height: 22px; cursor: hand;' onMouseOver=\"colorMe(this,'".$colour."');\" onMouseOut=\"plainJane(this,'".$colour."');\" ID='allocate_c".$result['credit_uid']."' COLOR_NOW='".$colour."' COLOR_RESTORE='".$colour."' BASTARD_AMOUNT='".($result['credit_amount']-$result['credit_paid'])."' BASTARD_COMMENTS='".$result['bank_comments']."'> <TD onClick=\"nailThis2(document.getElementById('allocate_c".$result['credit_uid']."'),'".$colour."', '".$result['credit_uid']."');\"> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0'> <TR> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD>".method_square('credit', $result['credit_uid'],'right')."</TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 50px;'><SPAN STYLE=' color: #333333;'>CN".$result['credit_uid']."</SPAN></DIV></TD> <TD><TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='color: #FFFFFF;'><TR><TD><IMG SRC='shim.gif' WIDTH='4' HEIGHT='1'></TD><TD><IMG SRC='rain_c.png'></TD></TR></TABLE></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 40px;'><SPAN STYLE=' color: #333333;'>".date('d M',$result['credit_created'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 150px;'><SPAN STYLE=' color: #333333;'>".$result['nome']."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 55px;'><SPAN STYLE=' color: #333333;'>$".($result['credit_amount']-$result['credit_paid'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 144px;'><SPAN STYLE=' color: #333333;'>".rawurldecode($result['credit_reason'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> </TR> </TABLE> </TD> <TD>".$insert2."<IMG SRC='reddollar.png' STYLE=' ".$insert." position: relative; top: 1px;'>".$insert3."</TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='position: relative; top: 1px;'><TR><TD><DIV ID='w_allo_noter".$result['bank_uid']."' STYLE='width: 13px; height: 13px; background: "; if($result['credit_notes']!='') { $note_on = 'yes'; } else { $note_on = 'no'; } if($note_on=='yes') { $allocate_c = $allocate_c."#0066CC; border: solid 1px #0066CC; "; } else { $allocate_c = $allocate_c."#94B7D1; border: solid 1px #6698BD; "; } $allocate_c = $allocate_c." color: #FFFFFF; font-size: 9px; cursor: hand;'><SPAN STYLE='' onClick=\"loadNote2('".$result['credit_uid']."');\"><CENTER>N</CENTER></SPAN></DIV></TD></TR></TABLE> </TD> <TD><IMG SRC='shim.gif' WIDTH='8' HEIGHT='1'></TD> <TD><IMG SRC='kharcross.gif' STYLE='position: relative; top: 1px; visibility: hidden;' onClick=\"deleteBankUID('".$result['bank_uid']."');\" ></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> </TR> "; // START ALL ************* // START ALL ************* // START ALL ************* if($allocate_all_tag == "1") { $colour = "D6CFAD"; //Dark Grey } if($allocate_all_tag == "-1") { $colour = "EDE7CB"; //Light Grey } $allocate_all_tag = $allocate_all_tag*-1; $allocate_all = $allocate_all." <TR STYLE='background:#".$colour."; height: 22px; cursor: hand;' onMouseOver=\"colorMe(this,'".$colour."');\" onMouseOut=\"plainJane(this,'".$colour."');\" ID='allocate_all_c".$result['credit_uid']."' COLOR_NOW='".$colour."' COLOR_RESTORE='".$colour."' BASTARD_AMOUNT='".($result['credit_amount']-$result['credit_paid'])."' BASTARD_COMMENTS='".$result['bank_comments']."'> <TD onClick=\"nailThis2(document.getElementById('allocate_all_c".$result['credit_uid']."'),'".$colour."', '".$result['credit_uid']."');\"> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' ID='check_customerc".$result['credit_uid']."' CUSTOMER='".$result['credit_customer']."'> <TR> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD>".method_square('credit', $result['credit_uid'],'right')."</TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 50px;'><SPAN STYLE=' color: #333333;'>CN".$result['credit_uid']."</SPAN></DIV></TD> <TD><TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='color: #FFFFFF;'><TR><TD><IMG SRC='shim.gif' WIDTH='4' HEIGHT='1'></TD><TD><IMG SRC='rain_c.png'></TD></TR></TABLE></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 40px;'><SPAN STYLE=' color: #333333;'>".date('d M',$result['credit_created'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 150px;'><SPAN STYLE=' color: #333333;'>".$result['nome']."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 55px;'><SPAN STYLE=' color: #333333;'>$".($result['credit_amount']-$result['credit_paid'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 144px;'><SPAN STYLE=' color: #333333;'>".rawurldecode($result['credit_reason'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> </TR> </TABLE> </TD> <TD>".$insert2."<IMG SRC='reddollar.png' STYLE=' ".$insert." position: relative; top: 1px;'>".$insert3."</TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='position: relative; top: 1px;'><TR><TD><DIV ID='w_allo_noter".$result['bank_uid']."' STYLE='width: 13px; height: 13px; background: "; if($result['credit_notes']!='') { $note_on = 'yes'; } else { $note_on = 'no'; } if($note_on=='yes') { $allocate_all = $allocate_all."#0066CC; border: solid 1px #0066CC; "; } else { $allocate_all = $allocate_all."#94B7D1; border: solid 1px #6698BD; "; } $allocate_all = $allocate_all." color: #FFFFFF; font-size: 9px; cursor: hand;'><SPAN STYLE='' onClick=\"loadNote2('".$result['credit_uid']."');\"><CENTER>N</CENTER></SPAN></DIV></TD></TR></TABLE> </TD> <TD><IMG SRC='shim.gif' WIDTH='8' HEIGHT='1'></TD> <TD><IMG SRC='shim.gif' WIDTH='1' HEIGHT='1'></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> </TR> "; // END ALL ************* // END ALL ************* // END ALL ************* // ADD IN MODULE FOR CREDIT NOTES ******************************************** FINISH // ADD IN MODULE FOR CREDIT NOTES ******************************************** FINISH // ADD IN MODULE FOR CREDIT NOTES ******************************************** FINISH } echo "document.getElementById('sub_allocate_w').innerHTML = unescape('".rawurlencode("<TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' onSelectStart='return false;'>".$allocate_w."</TABLE>")."');"; echo "document.getElementById('sub_allocate_a').innerHTML = unescape('".rawurlencode("<TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' onSelectStart='return false;'>".$allocate_a."</TABLE>")."');"; echo "document.getElementById('sub_allocate_j').innerHTML = unescape('".rawurlencode("<TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' onSelectStart='return false;'>".$allocate_j."</TABLE>")."');"; echo "document.getElementById('sub_allocate_c').innerHTML = unescape('".rawurlencode("<TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' onSelectStart='return false;'>".$allocate_c."</TABLE>")."');"; echo "document.getElementById('sub_allocate_all').innerHTML = unescape('".rawurlencode("<TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' onSelectStart='return false;'>".$allocate_all."</TABLE>'")."');"; $time_end = microtime_float(); $time = $time_end - $time_start; echo "alert('completed in ".$time." sec');"; } // end method refresh_allocate Quote Link to comment https://forums.phpfreaks.com/topic/108478-big-variable-high-cpu-why/#findComment-556285 Share on other sites More sharing options...
dave_biscuits Posted June 3, 2008 Author Share Posted June 3, 2008 .... and SECOND version: revised and cleaned up slightly to echo after each loop iteration of results ... function makeAllocateLine($category, $rain) { global $result; global $allocate_tag; if($allocate_tag[$category]=='') { $allocate_tag[$category] = '1'; } if($allocate_tag[$category] == "1") { $colour = "D6CFAD"; } else { $colour = "EDE7CB"; } $allocate_tag[$category] = $allocate_tag[$category]*-1; //if($results['nome']=='') { $results['nome'] = '?'; } echo $category." = ".$category."+unescape('".rawurlencode(" <TR STYLE='background:#".$colour."; height: 22px; cursor: hand;' onMouseOver=\"colorMe(document.getElementById('".$category."_".$result['bank_uid']."'),'".$colour."');\" onMouseOut=\"plainJane(document.getElementById('".$category."_".$result['bank_uid']."'),'".$colour."');\" ID='".$category."_".$result['bank_uid']."' COLOR_NOW='".$colour."' COLOR_RESTORE='".$colour."' BASTARD_AMOUNT='".$result['amount']."' BASTARD_COMMENTS='".$result['bank_comments']."'> <TD onClick=\"nailThis(document.getElementById('".$category."_".$result['bank_uid']."'),'".$colour."');\"> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0'> <TR> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD>".method_square($result['method'], $result['bank_uid'],'right')."</TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 50px;'><SPAN STYLE=' color: #333333;'>P".$result['bank_uid']."</SPAN></DIV></TD> <TD><TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='color: #FFFFFF;'><TR><TD><IMG SRC='shim.gif' WIDTH='4' HEIGHT='1'></TD><TD><IMG SRC='".$rain.".png'></TD></TR></TABLE></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 40px;'><SPAN STYLE=' color: #333333;'>".date('d M',$result['created'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 150px;'><SPAN STYLE=' color: #333333;'>".$result['nome']."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 55px;'><SPAN STYLE=' color: #333333;'>$".$result['amount']."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 144px;'><SPAN STYLE=' color: #333333;'>".rawurldecode($result['bank_comments'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> </TR> </TABLE> </TD> <TD> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='position: relative; top: 1px;'><TR><TD><DIV ID='w_allo_noter".$result['bank_uid']."' STYLE='width: 13px; height: 13px; background: "); if($result['bank_notes']!='') { $note_on = 'yes'; } else { $note_on = 'no'; } if($note_on=='yes') { echo rawurlencode("#0066CC; border: solid 1px #0066CC; "); } else { echo rawurlencode("#94B7D1; border: solid 1px #6698BD; "); } echo rawurlencode(" color: #FFFFFF; font-size: 9px; cursor: hand;'><SPAN onClick=\"loadNote('".$result['bank_uid']."');\"><CENTER>N</CENTER></SPAN></DIV></TD></TR></TABLE> </TD> <TD><IMG SRC='shim.gif' WIDTH='8' HEIGHT='1'></TD> <TD><IMG SRC='kharcross.gif' STYLE='position: relative; top: 1px;' onClick=\"deleteBankUID('".$result['bank_uid']."');\" ></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> </TR> "); echo "');"; // END OF FUNCTION } function makeAllocateLine_CREDIT($category, $rain) { global $result; global $allocate_tag; global $mesSsage; global $insert; global $insert2; global $insert3; if($allocate_tag[$category]=='') { $allocate_tag[$category] = '1'; } if($allocate_tag[$category] == "1") { $colour = "D6CFAD"; } else { $colour = "EDE7CB"; } $allocate_tag[$category] = $allocate_tag[$category]*-1; //if($results['nome']=='') { $results['nome'] = '?'; } echo $category." = ".$category."+unescape('".rawurlencode(" <TR STYLE='background:#".$colour."; height: 22px; cursor: hand;' onMouseOver=\"colorMe(this,'".$colour."');\" onMouseOut=\"plainJane(this,'".$colour."');\" ID='".$category."".$result['credit_uid']."' COLOR_NOW='".$colour."' COLOR_RESTORE='".$colour."' BASTARD_AMOUNT='".($result['credit_amount']-$result['credit_paid'])."' BASTARD_COMMENTS='".$result['bank_comments']."'> <TD onClick=\"nailThis2(document.getElementById('".$category."".$result['credit_uid']."'),'".$colour."', '".$result['credit_uid']."');\"> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0'> <TR> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD>".method_square('credit', $result['credit_uid'],'right')."</TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 50px;'><SPAN STYLE=' color: #333333;'>CN".$result['credit_uid']."</SPAN></DIV></TD> <TD><TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='color: #FFFFFF;'><TR><TD><IMG SRC='shim.gif' WIDTH='4' HEIGHT='1'></TD><TD><IMG SRC='rain_c.png'></TD></TR></TABLE></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 40px;'><SPAN STYLE=' color: #333333;'>".date('d M',$result['credit_created'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 150px;'><SPAN STYLE=' color: #333333;'>".$result['nome']."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 55px;'><SPAN STYLE=' color: #333333;'>$".($result['credit_amount']-$result['credit_paid'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD><DIV STYLE='width: 144px;'><SPAN STYLE=' color: #333333;'>".rawurldecode($result['credit_reason'])."</SPAN></DIV></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> </TR> </TABLE> </TD> <TD>".$insert2."<IMG SRC='reddollar.png' STYLE=' ".$insert." position: relative; top: 1px;'>".$insert3."</TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> <TD> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='position: relative; top: 1px;'><TR><TD><DIV ID='w_allo_noter".$result['bank_uid']."' STYLE='width: 13px; height: 13px; background: "); if($result['credit_notes']!='') { $note_on = 'yes'; } else { $note_on = 'no'; } if($note_on=='yes') { echo rawurlencode("#0066CC; border: solid 1px #0066CC; "); } else { echo rawurlencode("#94B7D1; border: solid 1px #6698BD; "); } echo rawurlencode(" color: #FFFFFF; font-size: 9px; cursor: hand;'><SPAN STYLE='' onClick=\"loadNote2('".$result['credit_uid']."');\"><CENTER>N</CENTER></SPAN></DIV></TD></TR></TABLE> </TD> <TD><IMG SRC='shim.gif' WIDTH='8' HEIGHT='1'></TD> <TD><IMG SRC='kharcross.gif' STYLE='position: relative; top: 1px; visibility: hidden;' onClick=\"deleteBankUID('".$result['bank_uid']."');\" ></TD> <TD><IMG SRC='shim.gif' WIDTH='5' HEIGHT='1'></TD> </TR> "); echo "');"; // END OF FUNCTION } if($_POST['method']=='refresh_allocate2') { $time_start = microtime_float(); $allocate_a = ''; $allocate_w = ''; $allocate_j = ''; $allocate_all = ''; $allocate_a_tag = '1'; $allocate_w_tag = '1'; $allocate_j_tag = '1'; $allocate_all_tag = '1'; if($special=='') { $special2 = " WHERE credit_status = 'issued' AND credit_amount <> credit_paid "; } else { $special2 = $special." AND credit_status = 'issued' AND credit_amount <> credit_paid "; } $results = ''; $query = "SELECT credits.*, customer.* from credits left outer join customer on (credits.credit_customer = customer.customer_no) ".$special2." order by credit_uid::integer DESC, credit_created::integer DESC; ;"; //echo "prompt('',unescape('".rawurlencode($query)."'));"; $query = pg_query($query); while($row = pg_fetch_array($query,NULL,PGSQL_ASSOC)) { $nome = ''; if($row['customer_surname']!='') { $nome = $row['customer_surname'].", ".$row['customer_firstname']; } else { $nome = $row['customer_name']; } if($row['customer_company']!='') { if($nome=='') { $nome = $row['customer_company']; } else { $nome = $nome." (".$row['customer_company'].")"; } } $row['nome'] = $nome; $results[] = $row; $last_cust = $row; } $credit_results = $results; if($special3=='') { $special3 = " WHERE bank_temporary.status = 'actual' AND bank_temporary.amount != '0' "; } $results = ''; $query = "SELECT bank_temporary.*, customer.* from bank_temporary left outer join customer on (bank_temporary.customer_uid = customer.customer_no) ".$special3." order by bank_uid::integer DESC, created::integer DESC; "; //echo "prompt('',unescape('".rawurlencode($query)."'));"; $query = pg_query($query); while($row = pg_fetch_array($query,NULL,PGSQL_ASSOC)) { $nome = ''; if($row['customer_surname']!='') { $nome = $row['customer_surname'].", ".$row['customer_firstname']; } else { $nome = $row['customer_name']; } if($row['customer_company']!='') { if($nome=='') { $nome = $row['customer_company']; } else { $nome = $nome." (".$row['customer_company'].")"; } } $row['nome'] = $nome; $results[] = $row; $last_cust = $row; } if($special!='') { echo "try { document.getElementById('allo_select_cust').innerHTML = \"<FONT STYLE='color: #009900;'><B>\"+unescape('".rawurlencode($last_cust['nome'])."')+\"</B></FONT>\"; } catch(e) { }"; if($last_cust['nome']=='') { echo "try { document.getElementById('allo_select_cust').innerHTML = \"<FONT STYLE='color: #990000;'><I>\"+unescape('".rawurlencode('No bankings under this customer.')."')+\"</I></FONT>\"; } catch(e) { }"; } } echo "var allocate_w = '';"; echo "var allocate_a = '';"; echo "var allocate_j = '';"; echo "var allocate_c = '';"; echo "var allocate_all = '';"; echo "var allocate_all_c = '';"; foreach ($results as $result) { if($result['customer_uid']=='') { makeAllocateLine('allocate_w','rain_w'); makeAllocateLine('allocate_all','rain_w'); } else { if($result['bank_category']=='banking') { makeAllocateLine('allocate_a','rain_a'); makeAllocateLine('allocate_all','rain_a'); } else { makeAllocateLine('allocate_j','rain_j'); makeAllocateLine('allocate_all','rain_j'); } } } // end foreach results foreach ($credit_results as $result) { // ADD IN MODULE FOR CREDIT NOTES ******************************************** START // ADD IN MODULE FOR CREDIT NOTES ******************************************** START // ADD IN MODULE FOR CREDIT NOTES ******************************************** START if($allocate_c_tag == "1") { $colour = "D6CFAD"; //Dark Grey } if($allocate_c_tag == "-1") { $colour = "EDE7CB"; //Light Grey } $allocate_c_tag = $allocate_c_tag*-1; //autoCred('".$row['credit_uid']."'); $temp = str_replace('%5E','',$result['credit_refinv']); $insert = ''; $insert2 = ''; $insert3 = ''; if(trim($temp)!='') { $insert = ""; $apply_data = ''; $apply_data = explode('^^',rawurldecode($result['credit_refinv'])); $precheck = ''; $ddata = ''; $supercounter = '0'; $mesSsage = ''; foreach ($apply_data as $ddata) { if($supercounter=='2') { $supercounter = '0'; if($failrate=='n') { $apply_counter++; $failrate = ''; } } if($supercounter=='0') { $precheck = $ddata; $supercounter++; continue; } if($supercounter=='1') { if((trim($precheck)!='') || (trim($ddata)!='')) { if($precheck=='') { $mesSsage = $mesSsage."<I>Job Unknown</I> "; } else { $mesSsage = $mesSsage.$precheck." "; } if($ddata!='') { $mesSsage = $mesSsage."($".$ddata.")"; } $mesSsage = $mesSsage."<IMG SRC='shim.gif' WIDTH='10' HEIGHT='1'>"; $failrate = 'n'; } $supercounter++; continue; } } //$mesSsage = 'blah'; if($mesSsage!='') { $mesSsage = "<DIV STYLE='width: 240px;'><SPAN STYLE=''><TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' STYLE='color: #333333;'><TR><TD>".$mesSsage."</TD></TR></TABLE></SPAN></DIV>"; $insert2 = "<FONT STYLE='color: #CC0000; cursor: help;' onMouseOver=\"smith('second', unescape('".rawurlencode($mesSsage)."')); document.all['smith'].style.display = 'block'; this.onmousemove = getMouseXY3;\" onMouseOut=\"document.all['smith'].style.display = 'none';\">"; $insert3 = "</FONT>"; } } else { $insert = "visibility: hidden;"; } makeAllocateLine_CREDIT('allocate_c','rain_c'); makeAllocateLine_CREDIT('allocate_all_c','rain_c'); } echo "allocate_all = allocate_all+allocate_all_c;"; echo "document.getElementById('sub_allocate_w').innerHTML = unescape('".rawurlencode("<TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' onSelectStart='return false;'>")."')+allocate_w+unescape('".rawurlencode("</TABLE>")."');"; echo "document.getElementById('sub_allocate_a').innerHTML = unescape('".rawurlencode("<TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' onSelectStart='return false;'>")."')+allocate_a+unescape('".rawurlencode("</TABLE>")."');"; echo "document.getElementById('sub_allocate_j').innerHTML = unescape('".rawurlencode("<TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' onSelectStart='return false;'>")."')+allocate_j+unescape('".rawurlencode("</TABLE>")."');"; echo "document.getElementById('sub_allocate_c').innerHTML = unescape('".rawurlencode("<TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' onSelectStart='return false;'>")."')+allocate_c+unescape('".rawurlencode("</TABLE>")."');"; echo "document.getElementById('sub_allocate_all').innerHTML = unescape('".rawurlencode("<TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' onSelectStart='return false;'>")."')+allocate_all+unescape('".rawurlencode("</TABLE>")."');"; /* echo "document.getElementById('sub_allocate_a').innerHTML = unescape('".rawurlencode("<TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' onSelectStart='return false;'>".$allocate_a."</TABLE>")."');"; echo "document.getElementById('sub_allocate_j').innerHTML = unescape('".rawurlencode("<TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' onSelectStart='return false;'>".$allocate_j."</TABLE>")."');"; echo "document.getElementById('sub_allocate_c').innerHTML = unescape('".rawurlencode("<TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' onSelectStart='return false;'>".$allocate_c."</TABLE>")."');"; echo "document.getElementById('sub_allocate_all').innerHTML = unescape('".rawurlencode("<TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' onSelectStart='return false;'>".$allocate_all."</TABLE>'")."');"; */ $time_end = microtime_float(); $time = $time_end - $time_start; //echo "alert('completed in ".$time." sec');"; } // end method refresh_allocate Quote Link to comment https://forums.phpfreaks.com/topic/108478-big-variable-high-cpu-why/#findComment-556286 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.