Jump to content


  • Posts

  • Joined

  • Last visited

About TapeGun007

  • Birthday 12/11/1968

Profile Information

  • Gender
  • Location
    San Diego, CA

TapeGun007's Achievements

Advanced Member

Advanced Member (4/5)




Community Answers

  1. Yes, the latter. Ok, so like INNER JOIN Deals ON Prospects.ProspectID = Deals.ProspectID; I mean something like that anyway I presume.
  2. Table "Deals": DealID (Yeah that's an L and then a capital i) Product Price Date Status (I only care about the deals that are marked as "won") ProspectID Table "Prospects": ProspectID FirstName LastName Address I could probably code this just fine, but I know it would be a horrible way to code it, so I'm asking for help on the proper way to code it. I want to display a deal that was sold, and then reference the first, last name and address of that deal. For example: Termite Treatment | $800 | 7-31-22 | Bob | Matthews | 123 Nowhere I suppose it should show the other way around too with the client info first and then each deal. I know that I could run the initial mySQL to pull the deal information and when it gets to the prospect id, run another query to pull the rest of the information, however, I am quite certain this would be the completely WRONG way to do it. Then I discovered the JOIN commands, and I assume it would be an INNER JOIN? The part where I get a little lost is that there are multiple deals under a Prospect. Any guidance would be appreciated.
  3. Very good gentlemen and thank you. I think I've just read so much that after awhile it seemed like I was getting conflicting opinions. This helps to clarify greatly!
  4. I've read quite a bit about Date, DateTime, TimeStamp, and Time that after awhile, it's gets a bit confusing because everyone seems to have an opinion about which is best to do what in code examples. All I really want to do is store an appointment say, 05/23/22 at 10:00 AM and store that into the database, and be able to recall it later in that same format. Then I want to store when that appointment is going to end (which will always be the same day). So what would be the best route to take, so I can narrow it down. Like it is better to store the appointment date under the Date field and a separate value for the time the appointment started, or would it make more sense to store the appointment start time with a DateTime stamp instead? The part I'm not understanding from reading, is which one do you use for what scenario. I mean, I think Date is pretty simple. The Time field is weird, but I can see how you could use it to track the variance in time rather than a set calendar-like time like I'm doing. I believe I'm correct in saying that TimeStamp is really for tracking changes like... to a record and perhaps you have a timestamp for every time the record changes? I *think* I should use the DateTime for the start of the appointment and maybe just TimeStamp for the end of the appointment? Any advice or perhaps a link to better reading material would be greatly appreciated.
  5. That did the trick. Thank you kindly as always. Yeah, the while is correct as there can be multiple entries in a day.
  6. Oh I did exactly what was posted. I've just been super busy at work. I was contemplating just rewriting the entire page, but I just cannot find the time at the moment. Here is the entire piece of code: The rc_date is a Date field in the mySQL database. I used to have a well written calendar page, but... *sigh*... I cannot find it anywhere.
  7. @Barand, yes I know it's horrible code. I didn't write it. I was just trying to get it functional until I could get back to it and rewrite the entire page. @mac_gyver, yes it's in a loop. It's a calendar generated with HTML <table>'s. The echo was just to see what the db was outputting. As the calendar would come up to a specific date like today, it would bring up whatever was stored in the db called RepairCalendar for that date. There are deprecated HTML attributes being used in the code, so I have to correct all of that as well. Very fun. I'll probably just rewrite the page from the ground up.
  8. In mySQL, I have a date field rc_date and it's formatted Y-m-d. I'm not sure if I have done this right...and I've read a ton of examples but here is the code: $sqlDate = $numYear."/".$numMonth."/".$i; $temp = date_create($sqlDate); $sqlDate = date_format($temp, "Y-m-d"); echo $sqlDate; $sql = "SELECT * FROM RepairCalendar WHERE DATE(rc_date) = '".$sqlDate."'"; $stmt = $pdo->prepare($sql); $stmt->execute(); This is by no means optimized code. When I output echo $row['rc_date']; there is nothing. In the $sql statement, I tried just putting rc_date = $sqlDate. I tried using date_format in comparing the two dates as well which nothing seems to work. Whatever the case, I'm stumped as to what I'm doing wrong after reading so many examples. I had the echo statement just to ensure that the $sqlDate coming out correctly.
  9. Hrmmm.... I see. I was thinking the error was related to the issue where if I draw a line on the canvas, and then double click it, the red circles are supposed to draw at the beginning and ending of the line. The code to resize the line isn't yet implemented as I've been stuck on why the red circles do not draw when double clicking on the line. Apparently, it's unrelated and so back to the drawing board.
  10. I'm getting this error and I'm not sure what's causing it. I'm a little newer to JS. I'm using the fabric framework so to speak. It takes place on line 101 in the function updateNewLineCoordinates where it says: I am hoping someone can help me fix the error. Here is the code: let canvas = new fabric.Canvas("canvas", { width: window.innerWidth, height: window.innerHeight }); let addingLineBtn = document.getElementById('adding-line-btn'); // DrawBtn is the button pressed let addingLineBtnClicked = false; addingLineBtn.addEventListener('click', activateAddingLine); // call function activeAddingLine, then define it later function activateAddingLine() { if(addingLineBtnClicked===false) { // If you don't set this to false, then each time you click the Draw Line button, you have to also click the Select button or it will draw a new line when dragging another. addingLineBtnClicked = true; canvas.on('mouse:down', startAddingLine); // when mouse is down call function startAddingLine canvas.on('mouse:move', startDrawingLine); canvas.on('mouse:up', stopDrawingLine); canvas.selection = false; // this keeps the default selection box turned off. I want that option only when I choose to have it. canvas.hoverCursor = 'auto'; // When hovering over a line, it does not show that default MOVE cursor with 4 arrows. objectSelectability('added-line', false); } } let line; // Make a global variable so it can be called in other functions let mouseDown = false; // must be set to false so it can be "True" when actually pressed function startAddingLine(o) { mouseDown = true; let pointer = canvas.getPointer(o.e); line = new fabric.Line([pointer.x, pointer.y, pointer.x, pointer.y], { // we need 4 coordinates x,y where the line started, and x,y where it ended id: 'added-line', stroke: 'black', strokeWidth: 3, selectable: false // Set so you won't drag a drawn line on accident, but the move cursor pops up by default anyway. }); canvas.add(line); // will draw the line canvas.requestRenderAll(); // now rend the draw line being drawn } function startDrawingLine(o) { if(mouseDown===true) { let pointer = canvas.getPointer(o.e); line.set({ x2: pointer.x, // x2: Math.round(number / 10) * 10, // Not sure if this will round to closets 10 or not since line won't draw. y2: pointer.y }); canvas.requestRenderAll(); // Will actually render the line drawn } } function stopDrawingLine() { line.setCoords(); // This must be set for fabric to store the location of the line drawn so you can store or select it later. mouseDown = false; // set mouseDown to false so it will quit drawing the line } let deactivateAddingShapeBtn = document.getElementById('deactivate-adding-shape-btn'); deactivateAddingShapeBtn.addEventListener('click', deactivateAddingShape) function deactivateAddingShape(){ canvas.off('mouse:down', startAddingLine); // These functions now turn canvas.off so it will no longer keep drawing. canvas.off('mouse:move', startDrawingLine); canvas.off('mouse:up', stopDrawingLine); objectSelectability('added-line', true); canvas.hoverCursor = 'all-scroll'; // set cursor to the drag icon when hovering in area. addingLineBtnClicked = false; // Set to false or you will not be able to draw in the addingActivateLine function. } function objectSelectability(id,value) { canvas.getObjects().forEach(o => { // without this little bit of code, original lines drawn will be moveable without hitting the select button and when selecting and moving, it will draw another line. if(o.id===id) { // this is bascially a bug fix for drawing lines because of the way the buttons we programmed work. o.set({ // Youtube for this reasoning can be found here: https://www.youtube.com/watch?v=IQgeefO849w&list=PL-gIJFyHJjykXg776HNz3H7XXzBMSu5mL&index=4 selectable: value }) } }); } canvas.on({ // this is so that when you move the line, the dblclick circles on the ends move with it. 'object:moved': updateNewLineCoordinates, 'selection:created': updateNewLineCoordinates, 'selection:updated': updateNewLineCoordinates, 'mouse:dblclick': addingControlPoints }); let newLineCoords = {}; function updateNewLineCoordinates(o) { // this calculates from center of line and uses the offsets of x,y to move editing circles with the line. newLineCoords = {}; let obj = o.target; if(obj.id==='added-line') { let centerX = obj.getCenterPoint().x; // Gets the X coordinate of the center of the line drawn let centerY = obj.getCenterPoint().y; // Gets the Y coordinate of the center of the line drawn let x1offset = obj.calcLinePoints().x1; // Now calculate the end beginng and ending of each line to place the red circle for editing the line (so you can drag and make the line bigger or shorter) let y1offset = obj.calcLinePoints().y1; let x2offset = obj.calcLinePoints().x2; let y2offset = obj.calcLinePoints().y2; newLineCoords = { // places circle at the end of each line x1, y1 being the beginning of the line x1: centerX+x1offset, y1: centerY+y1offset, x2: centerX+x2offset, y2: centerY+y2offset } } } w function addingControlPoints(o) { let obj = o.target; if(!obj) { // If there is no object, then strokeWidth is not defined so it will throw an error in console. return; } else { if(obj.id==='added-line') { // All lines are given the 'added-line' id so we can select them later. let pointer1 = new fabric.Circle({ // These circles are so you can resize the line, there are no defaults for this, so we are creating it. radius: obj.strokeWidth*3, fill: 'red', opacity: 0.5, top: newLineCoords.y1, left: newLineCoords.x1, originX: 'center', // these two lines place the red editing circle dead center on the end of the line. originY: 'center' }); let pointer2 = new fabric.Circle({ // This is the other end of that line we want to resize. radius: obj.strokeWidth*3, fill: 'red', opacity: 0.5, top: obj.y2, left: obj.x2, originX: 'center', // these two lines place the red editing circle dead center on the end of the line. originY: 'center' }); canvas.add(pointer1,pointer2); canvas.requestRenderAll(); } } }
  11. So... I'm more of a PHP/mySQL guy. I'm going to be attempting to program a graph drawing type of program that I want to be specifically web based. Here is what I would like to accomplish (hopefully, it will make sense): I need a grid just like graph paper, only smaller, tighter squares. I want to draw lines that will snap to that grid. While the line is being drawn, it should say how many feet that line is. Once the line is drawn, I should be able to select it and move it or resize it. It needs to work with both mouse and touchscreen. I want to be able to save the graph and all the drawings on it and be able to recall them later. I have found a few examples that do various elements of the above, but I cannot seem to figure out how to combine them into a single program. If you have any places I can go to read about this, I'm more than willing to read and learn. Basically, I'll be graphing homes from a birds eye perspective. Here is my work so far: https://depests.com/leads/test/graph2.html - This has a graph and the object snaps to grid. https://depests.com/leads/test/test2.html - This allows me to draw lines, but they don't snap to a grid. https://depests.com/leads/test/test3.html - This tracks mouse and/or ipad touch movement, so I have something as sort of a guide on touch/mouse functionality.
  12. Barand, Thanks as always. I did discover through my trials and errors that the conditions in the WHERE clause were causing some issues. After much reading I had put them in the JOIN ON section, but you confirmed what I wasn't 100% sure of. So your definition confirms also that I was supposed to use the INNER JOIN because I did only want to show records if the match was in both tables. I did not know that LEFT JOINS were much slower however, that part I had not yet discovered.
  13. Is this a less correct way to write it then? This gave me the result I was looking for, but being a bit OCD, I like to ensure I'm writing solid code. SELECT * FROM Deals INNER JOIN Prospects ON Prospects.ProspectID = Deals.ProspectID AND Deals.Status = 'Won' AND Deals.PIGLead = ? ORDER BY SoldDate DESC Yeah, I just put the * in there to shorten it.
  14. Ok never mind. I got it. I had to use an INNER JOIN. I had also made an error above, the Status column was set to "Won" not "Sold". Thanks for helping me get on the right path.
  15. ON Prospects.ProspectID = Deals.ProspectID AND Deals.PIGLead = 2 WHERE Deals.Status = 'Sold' So... the ON line works sort of, but it lists clients that nothing was sold to. So I tried the WHERE above and now nothing comes up. LOL.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.