
NerdConcepts
Members-
Posts
153 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
NerdConcepts's Achievements

Regular Member (3/5)
0
Reputation
-
Seemed so simple when I started. I can easily subtract time (working with hours/minutes/seconds...00:00:00 format), but 5 hours of doing one thing after another I'm done, time to ask for him. I've tried just using MySQL and tried using PHP only, then tried both and still nothing. For some reason when using a simple (note: values or given not variables, first time is from DB, second is simulated current time) mysql_query("SELECT TIMEDIFF('08:45:00', '09:00:00'')"); returns -00:15:00 mysql_query("SELECT TIMEDIFF('09:15:00', '09:00:00')"); returns 00:15:00 Is there a way to take the 00:15:00 and convert it just into minutes, so I know if it is -15 or 15? I know that would work but cannot figure it out. I need to run a command if the value is 15-6 and a different one if the value is 5 or less. So if, example, I had 9am as current time and list time is 11am it would return "120' thus not running either of my commands... Hope my explanation explains it...
-
Ok, what I am doing: I take a 1meg+ .html file and I insert a special tag as a file breaker. I think break apart that large HTML file in multiple parts (depending on how many work orders are actually in the file) in my test it's 43 different .html files. All this works great. This is where I do not have a clue to begin. I need to then scan a directory (the directory only has the new broken apart html files in it) and for each of those files I want to search the contents for a phrase "WORK ORDER NUMBER: " (yes a space after it) because then I want to count forward 17 characters exactly and that will give me that files work order number. From there rename the file (0.html - 43.html) to that work order number. I've search a bunch of stuff and tested a whole lot more and cannot get any of this to work. I've tried doing the search/count then rename by specific file names even and can't seem to get a grasp on it. Anyone have a clue on this? Once I can figure this out I'll be modifying the files even more but I know how to do that. the actual line of code looks like this: "Work Order: 55674999931224051</span>" even if I could just grab that whole line of code, I could then eregi_replace the "Work Order: " with nothing and the "</span>" with nothing and that would give me the Work Order Number itself. Just a thought. Still have no clue on how to locate that line, or how to "pull" it out of the html file. Here is what I am doing so far (that works). // ADD KEY TAG - WORKS $file = 'test.html'; $file_contents = file_get_contents($file); $fh = fopen($file, "w"); $file_contents = str_replace('<div class="pos" id="_0:0"','<KEYTAG><div class="pos" id="_0:0"',$file_contents); fwrite($fh, $file_contents); fclose($fh); // BREAK FILE APPART - WORKS $file_contents = file_get_contents($file); $ex = explode('<KEYTAG>',$file_contents); $ctr = 0; foreach ($ex as $x) { $file = fopen('break/' . $ctr . '.html', 'w'); $contents = $ex[$ctr]; fwrite ($file,$contents); fclose($file); $ctr++; }
-
[SOLVED] Calculation formula problem dealing with days
NerdConcepts replied to NerdConcepts's topic in PHP Coding Help
What I am looking for is a way to calculate how many does back is the previous Thursday. Or whatever day I set in the database. I do believe I have figured it out. Not sure why I didn't think about it before. $now = strtotime("Now"); $dotw = date("N", $now); $dotw = $dotw + 1; // doing this to get a positive number $payend = $row['pay_on'] + 1; // Thursday: 4, adding 1 to ensure positive number for math $paytime = $row['pay_duration']; // 7 days if ($dotw > $payend) { $countback = $dotw - $payend; } elseif $dotw < $payend) { $countback = $dotw + (7 - $payend); } else { $countback = 7; } $end_date = strtotime("-" . $countback . " days"); That in theory gives me the the end date of the previous payroll week. Haven't tested it, but in theory it will (no matter which days are set in the database) give me the number of days back that the previous work week ends on, then I calculate the actual date of the date, and use the total number of days in a pay period (in this case 7) and I'll have the two dates needs for a database query. Now Time to test it, -
This seems to be a massive problem that I am having and have tried tons of things to figure it out and cannot seem to write a formula to deal with it. This is calculating payroll dates Here is what is stored in the database example values:: Pay Period: 7 days Pay Roll Ends: Thursday I don't need a begin day, since it takes the end date and counts back however days the pay period is, takes those dates and grabs payroll. In this example the whole pay period ends up being Friday-Thursday I cannot figure out to calculate the number of days from Wednesday to the previous Thursday. Yes, I know it's 6 days, but what if these days change? The number of days that have to be counted back to get the end of the pay week changes. Example: if christmas falls on wednesday and we do payroll on monday. We will want the previous Thursday to come up (like normal), not the full 6 days back. Here is how I get the day of the week that it currently is. $now = strtotime("Now"); $dotw = date("N", $now); that returns the day number. ie: Sunday=0, Saturday=6 but how in the heck do you calculate from days day of the week to last Thursday, find out how many days back that is...I have to figure it out since I will be making actual dates to query the database to grab invoices and what not. Am I just going about this all wrong or something? if the database needs some changes, that is fine. I am the only one working on this. I do have a lot of test pieces done already but that is with me forcing 6 days and faking that today is Wednesday. note: I have read this over multiple times and hope it's not to confusing....
-
The thing is, there was an "answer" but people do like to actually get a solution. Not just, write a class. But maybe an existing class? And, yes here it is and how to do it! Go and download this... http://sourceforge.net/project/shownotes.php?release_id=620047 1) Drop the contents of the download into a subdirectory of your website. Example of mine: http://localhost/testapp/tcpdf/ 2) Write a PHP file to contains your form. Make sure to read the documentation (some HTML is no acceptable)..for example... "form2pdf.php" 3) Create a PHP file that contains the following code. require_once('tcpdf/config/lang/eng.php'); require_once('tcpdf/tcpdf.php'); $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->setLanguageArray($l); $pdf->AliasNbPages(); $pdf->SetFont("helvetica", "", 10); $pdf->AddPage(); $htmlcontent = file_get_contents("form2pdf.php", false); $pdf->writeHTML($htmlcontent, true, 0, true, 0); $pdf->Output("example.pdf", "I"); And run the this PHP file, it will auto generate the PDF and display it on the screen. That is just a simple test that I just now did for my solution. Still going through the TCPDF coding to change somethings on it to personalize it to work better for what I am doing. Also go through the examples, there are LOTS of different applications for this class file. Hope this helps.
-
is there a way to convert an outside PHP file into a PDF? That may do the job for a few of us. I know it would me. It would allow me to recreate the PDF into HTML and PHP to fill in the needed values and then covert the code over to PDF.
-
Yeah, seriously? Anyone? This is on going HUGE problem that I am having to finish up some stuff I've been working on a long time. Tried lots of things, I attempted to just open the file using what build in PDF stuff with a build in library on my server, HA, not even close. Tried a few other classes. tcpdf seemed like it may work, but it has so much junk tied with it I am not sure if that would be the way to go, since I am still not sure if you can simply open the existing form PDF, add text to it (using x,y) then save it. I know you can do the adding and saving and what not, but the whole opening an existing PDF is beyond me. I am checking to see if I can do a simple "background" image on a table and use PHP to fill in the variables and use tcpdf to use that PHP file to generate a PDF, but again, not sure if this is possible, since it seems to be overly complicated at this point. Haven't had a whole lot of time to check it out but I thought I would bring this to light to maybe the people having problems might also figure it out or find it useful.
-
Ok, I did figure out what I causing this. It is the "Niceforms 1.0" script(s). I am running the fix for it, that enables the Select box onChange to work properly. But the problem is, that doesn't seem to work anymore. I've applied a few different "fixes" for this and nothing seems to fix it. Here is the command that is throwing the error. function selectMe(selectFieldId,linkNo,selectNo) { //feed selected option to the actual select field selectField = document.getElementById(selectFieldId); value = selectField.value; // FIX CODE for(var k = 0; k < selectField.options.length; k++) { if(k==linkNo) {selectField.options[k].selected = "selected";} else {selectField.options[k].selected = "";} } //show selected option textVar = document.getElementById("mySelectText"+selectNo); var newText = document.createTextNode(selectField.options[linkNo].text); textVar.replaceChild(newText, textVar.childNodes[0]); if(value!=selectField.value) {eval(selectField.getAttribute("onChange").replace(/this.value/g, selectField.value));} // FIX CODE } If I remove the two lines that have "// FIX CODE" after them, no error, but the onchange doesn't do anything. I have no idea what is going on now.
-
The error says Line: 295 Char: 32 Error: object doesn't support this property or method Code: 0 URL: xx Here is my code for the select box.... <form method="post" name="vehicleselect" id="vehicleselect" class="niceform" style="border: 0; padding: 0; margin: 0;"> <select name="vehicle" id="vehicle" onChange="document.vehicleselect.submit()" class="width_200_height_150"> <option value="1">Test Vehicle 1</option> <option value="2">Test Vehicle 2</option> <option value="3">Test Vehicle 3</option> </select> <noscript><input type="submit" name="submit" id="submit" value="update"></noscript> <input type="hidden" name="subVehicleSelect" value="TRUE" /> </form> This just started happening out of the blue. Everything was working perfectly with IE7 and 6 and now the page loads just fine. When I make a selection is when the "Error on page" at the bottom pops up. Firefox is still working fine though. Any clues?
-
Sorry I'm sure this is something really simple but I cannot seem to find any information on it. Not much of a javascript guy, more of a PHP one. What I am trying to do is use a form that posts the information to an external tracking system that I have no influence over. Basically it posts a name and email address to a tracking website so I cannot influence the form code at all. But what I want it to do is open a new window with just a pdf file download. This seems more like a simple javascript line on a form button then something easily done with PHP. Not sure if I maybe confusing someone, but it will do the following I do have another question. Is it possible to do 3 things with a single form? 1) Have it submit the form data to the external page (basically opening another frame to do so), 2) Open another window with the file download and 3) in the main window redirect to another website? Just wondering if this is possible with Javascript or should I maybe look into a solution with my "native language" (php). Thanks a bunch.
-
This work perfect in Firefox, but not IE7. What it does is when you mouseover a link it display a hover box with information in it. Here is the stuff that create that box: I've tried searching for known issues with this and nothing. No luck. I have not messed with the script at all. So I'm not sure why IE7 won't display it. The links to the MouseOvers are inside a table. Not sure if this is effecting the display, but in theory it shouldn't. <script type="text/javascript"> var docTips = new TipObj('docTips'); with (docTips) { template = '<table bgcolor="#FF0000" cellpadding="1" cellspacing="0" width="%2%" border="0">' + '<tr><td><table bgcolor="#FFFFFF" cellpadding="5" cellspacing="0" width="100%" border="0">' + '<tr><td class="tipClass">%3%</td></tr></table></td></tr></table>'; tips.comment1 = new Array(20, 5, 200, 'Display Text Goes Here'); } </script> This is how you get it to work on a link: <a href="#" onMouseOver="docTips.show('comment1')" onMouseOut="docTips.hide()">MouseOver</a> This is the javascript code (inside tipster.js) var isDOM=document.getElementById?1:0, isIE=document.all?1:0, isNS4=navigator.appName=='Netscape'&&!isDOM?1:0, isOp=self.opera?1:0, isDyn=isDOM||isIE||isNS4; function getRef(i, p) { p=!p?document:p.navigator?p.document:p; return isIE ? p.all[i] : isDOM ? (p.getElementById?p:p.ownerDocument).getElementById(i) : isNS4 ? p.layers[i] : null; }; function getSty(i, p) { var r=getRef(i, p); return r?isNS4?r:r.style:null; }; if (!self.LayerObj) var LayerObj = new Function('i', 'p', 'this.ref=getRef(i, p); this.sty=getSty(i, p); return this'); function getLyr(i, p) { return new LayerObj(i, p) }; function LyrFn(n, f) { LayerObj.prototype[n] = new Function('var a=arguments,p=a[0],px=isNS4||isOp?0:"px"; ' + 'with (this) { '+f+' }'); }; LyrFn('x','if (!isNaN(p)) sty.left=p+px; else return parseInt(sty.left)'); LyrFn('y','if (!isNaN(p)) sty.top=p+px; else return parseInt(sty.top)'); LyrFn('w','if (p) (isNS4?sty.clip:sty).width=p+px; ' + 'else return (isNS4?ref.document.width:ref.offsetWidth)'); LyrFn('h','if (p) (isNS4?sty.clip:sty).height=p+px; ' + 'else return (isNS4?ref.document.height:ref.offsetHeight)'); LyrFn('vis','sty.visibility=p'); LyrFn('write','if (isNS4) with (ref.document){write(p);close()} else ref.innerHTML=p'); LyrFn('alpha','var f=ref.filters,d=(p==null),o=d?"inherit":p/100; if (f) {' + 'if (!d&&sty.filter.indexOf("alpha")==-1) sty.filter+=" alpha(opacity="+p+")"; ' + 'else if (f.length&&f.alpha) with(f.alpha){if(d)enabled=false;else{opacity=p;enabled=true}} }' + 'else if (isDOM)sty.opacity=sty.MozOpacity=o'); if (!self.page) var page = { win:self, minW:0, minH:0, MS:isIE&&!isOp }; page.db = function(p) { with (this.win.document) return (isDOM?documentElement[p]:0)||body[p]||0 }; page.winW=function() { with (this) return Math.max(minW, MS ? db('clientWidth') : win.innerWidth) }; page.winH=function() { with (this) return Math.max(minH, MS ? db('clientHeight') : win.innerHeight) }; page.scrollX=function() { with (this) return MS ? db('scrollLeft') : win.pageXOffset }; page.scrollY=function() { with (this) return MS ? db('scrollTop') : win.pageYOffset }; function TipObj(myName) { this.myName = myName; this.template = ''; this.tips = new Array(); this.parentObj = null; this.div = null; this.actTip = ''; this.showTip = false; this.xPos = this.yPos = this.sX = this.sY = this.mX = this.mY = 0; this.trackTimer = this.fadeTimer = 0; this.alpha = 0; this.doFades = true; this.minAlpha = 100; this.maxAlpha = 100; this.fadeInSpeed = 20; this.fadeOutSpeed = 20; this.tipStick = 1; this.showDelay = 50; this.hideDelay = 250; this.IESelectBoxFix = 0; TipObj.list[myName] = this; }; TipObj.list = {}; var ToPt = TipObj.prototype; ToPt.track = function(evt) { with (this) { if (!isIE || document.body) { evt=evt||window.event; sX = page.scrollX(); sY = page.scrollY(); mX = evt.pageX || sX + evt.clientX || 0; mY = evt.pageY || sY + evt.clientY || 0; if (tipStick == 1) position(); } }}; ToPt.position = function(forcePos) { with (this) { if (!actTip) return; var wW = page.winW(), wH = page.winH(); if (!isIE||isOp) { wW-=16; wH-=16 } var t=tips[actTip], tipX=eval(t[0]), tipY=eval(t[1]), tipW=div.w(), tipH=div.h(), adjY = 1; if (typeof(t[0])=='number') tipX += mX; if (typeof(t[1])=='number') tipY += mY; if (tipX + tipW + 5 > sX + wW) tipX = sX + wW - tipW - 5; if (tipY + tipH + 5 > sY + wH) tipY = sY + wH - tipH - 5; if (tipX < sX + 5) tipX = sX + 5; if (tipY < sY + 5) tipY = sY + 5; if ((!showTip && (doFades ? !alpha : true)) || forcePos) { xPos = tipX; yPos = tipY; } xPos += (tipX - xPos) * tipStick; yPos += (tipY - yPos) * tipStick; div.x(xPos); div.y(yPos); return; }}; ToPt.replaceContent = function(tipN) { with (this) { actTip = tipN; if (tipStick == parseInt(tipStick)) { var rE = ''; if (isNS4) { div.ref.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT); rE = '; return this.routeEvent(evt)'; } div.ref.onmouseover = new Function('evt', myName+'.show("' + tipN + '"' + (parentObj ? ','+parentObj.myName : '') + ')' + rE); div.ref.onmouseout = new Function('evt', myName + '.hide()' + rE); } var str = template; for (var i = 0; i < tips[tipN].length; i++) str = str.replace(new RegExp('%'+i+'%', 'g'), tips[tipN][i]); if (window.createPopup && IESelectBoxFix) { var filt = 'filter: progid:DXImageTransform.Microsoft.Alpha(opacity='; str += '<iframe src="about:blank" style="position: absolute; left: 0px; top: 0px; ' + 'height: expression(' + myName + '.div.h()); z-index: 1; border: none; ' + filt + '0)"></iframe>' + '<div style="position: absolute; left: 0px; top: 0px; z-index: 2; ' + filt + '100)">' + str + '</div>'; } if (isDOM&&!isOp) div.sty.width = 'auto'; div.write(str + (isIE&&!isOp&&!window.external ? '<small><br /></small>' : '')); position(true); }}; ToPt.show = function(tipN, par) { with (this) { if (!isDyn) return; // Clear any pending hides. clearTimeout(fadeTimer); parentObj = par; if (par) par.show(par.actTip, par.parentObj); if (!div) div = getLyr(myName + 'Layer'); if (!div) return; clearInterval(trackTimer); if (tipStick != parseInt(tipStick)) trackTimer = setInterval(myName+'.position()', 50); var showStr = 'with ('+myName+') { showTip = true; ' + (actTip!=tipN ? 'replaceContent("'+tipN+'"); ' : '') + 'fade() }'; if (showDelay && !actTip) fadeTimer = setTimeout(showStr, showDelay); else eval(showStr); }}; ToPt.newTip = function(tName) { with (this) { if (!tips[tName]) tips[tName] = []; for (var i = 1; i < arguments.length; i++) tips[tName][i-1] = arguments[i]; show(tName); return; }}; ToPt.hide = function() { with (this) { clearTimeout(fadeTimer); if (!isDyn || !actTip || !div) return; if (isNS4 && tipStick==0 && xPos<=mX && mX<=xPos+div.w() && yPos<=mY && mY<=yPos+div.h()) return; with (tips[actTip]) if (parentObj) parentObj.hide(); fadeTimer = setTimeout('with (' + myName + ') { showTip=false; fade() }', hideDelay); return; }}; // Called recursively to manage opacity fading and visibility settings. ToPt.fade = function() { with (this) { clearTimeout(fadeTimer); if (showTip) { div.vis('visible'); if (doFades) { alpha += fadeInSpeed; if (alpha > maxAlpha) alpha = maxAlpha; div.alpha(alpha); if (alpha < maxAlpha) fadeTimer = setTimeout(myName + '.fade()', 75); } } else { if (doFades && alpha > minAlpha) { alpha -= fadeOutSpeed; if (alpha < minAlpha) alpha = minAlpha; div.alpha(alpha); fadeTimer = setTimeout(myName + '.fade()', 75); return; } div.vis('hidden'); actTip = ''; clearInterval(trackTimer); } }} var tipOR=window.onresize, nsWinW=window.innerWidth, nsWinH=window.innerHeight; document.tipMM = document.onmousemove; if (isNS4) document.captureEvents(Event.MOUSEMOVE); document.onmousemove = function(evt) { for (var t in TipObj.list) TipObj.list[t].track(evt); return document.tipMM?document.tipMM(evt):(isNS4?document.routeEvent(evt):true); }; // Handle NS4 resizing error, don't worry about Opera 5/6 as they can't run this anyway. window.onresize = function() { if (tipOR) tipOR(); if (isNS4 && (nsWinW!=innerWidth || nsWinH!=innerHeight)) location.reload(); };
-
When I started looking at examples it seemed as though this was going to work...but I don't know enough about javascript to make it work. The issue is that there are upwards to 100 of those select boxes on each days page. What it does is you select the employee to assign to it, which you can whichever you want for whatever job you want and at the bottom you update with a form button. That data is put into an array with PHP and then moved to updating a database. The problem I have is that the menu's expand the table and are limited to the table that the select is displayed in. Hmmm, not sure what to do here except make the data display on two rows but that just won't work. Instead of printing off 100 lines I would be printing off 200. Just not working how I imagined, lol. If anyone else has any idea or whatever, please feel free to post. http://rewerkd.net/display_issue.jpg EDIT: uploaded an image of the issue, so it might help visually.
-
This is not a problem in Firefox, just IE. I have a select box, dynamic from SQL, that isn't the problem. The width has to be 53px so only a employee's number shows up, the problem is when you actually click to display the whole select options, the width of the option display stays at 53px, so you cannot see the employee's name. In firefox, when you click to display all the select options it automatically expands the display (not what has been selected, just the dropped down options) in it's full width, so you see their ID number and Name. Just wondering if there is a fix to this problem. Note sure if this helps any, here is the code. echo '<select name="uid[]" style="width: 53px">'; echo '<option></option>'; $uiQ = mysql_query("SELECT user_id FROM market_users WHERE (mgt_code='{$wo['wo_mgtarea']}') ORDER BY mgt_code ASC"); while ($uiR = mysql_fetch_array($uiQ, MYSQL_NUM)) { $queryN = mysql_query("SELECT user_name FROM users WHERE user_id='{$uiR[0]}' LIMIT 1"); $rowN = mysql_fetch_array($queryN, MYSQL_NUM); if ($wo['user_id'] == $uiR[0]) { echo '<option value="' . $uiR[0] . '" selected="selected">(' . $uiR[0] . ') ' . $rowN[0] . '</option>'; } else { echo '<option value="' . $uiR[0] . '">(' . $uiR[0] . ') ' . $rowN[0] . '</option>'; } } echo '</select>';
-
I am trying to figure out the best way to make sure only one user is logged in to each account on my website. I thought about using database to do this, but then if the user doesn't logout I don't know of a way to automatically (when the browser is closed, or session timeout) the database entry changes to reflect this. My other thought was to do a custom session variable with the user ID in it. Then when someone tries to login and it sees that, that user_id has already been assigned a session it won't allow another login. Is there a way to do this?
-
[SOLVED] Stupid onMouseOver question
NerdConcepts replied to NerdConcepts's topic in Javascript Help
it's actually: document.getElementById('imagechange'.className just have to leave out the ".style" But it works perfectly now...thanks a bunch!