|
#1
|
|||
|
|||
![]() I need a bit of help building a checklist system into my Staff Viewticket page. This is just for internal use so that we can tell where we are on certain repairs and what-not. Unfortunately, like so many, I am not a programmer. Actually before OsTicket and this great forum (thanks by the way!) I had never coded anything more difficult than a batch file. I have built the form with checkboxes, and found how to Implode the created array into a usable string. However thats where i faulter. I have created 2 new "fields" mostly as described here: http://osticket.com/forums/showthrea...ighlight=field I have omitted a couple of places it was not needed, like new ticket creation. 1 field (malinfect) will be strickly an interger (although specified in the database as text, to mimick the other and allow for testing) and functions perfectly. field 2 (clist) will contain the checklist data. Now the problem is assigning the imploded array to $tickets->getclist() to be updated in the database. Anytime i try, it only returns "clist" vs. 'HDD,antivir' as it is supposed to. Here is the code i have so far for the form: HTML Code:
<script type="text/javascript"> function toggle(chkbox, group) { var visSetting = (chkbox.checked) ? "block" : "none"; document.getElementById(group).style.display = visSetting; } </script> <table> <tr><td> <b>Tune-Up</b> <input type="checkbox" name="list" value="Tune-Up" onclick="toggle(this,'tuneup')" /> <b>OS Load</b> <input type="checkbox" name="list" value="OS Load" /> <b>Data Transfer</b> <input type="checkbox" name="list" value="Data Transfer" /> </tr></td> <tr><td><div id="tuneup" style="display: none;"> <form name="tunelist" action='tickets.php?id=<?=$id?>' method="post"> <input type='hidden' name='a' value="update2"/> <br/><input type="checkbox" name="clista[]" value='HDD'> <b>HDD Diag</b><br/> <input type="checkbox" name="clista[]" value="antiv"> <b>Check Anti-Virus</b><br/> <input type="checkbox" name="clista[]" value="excessprograms"> <b>Remove Excess Programs</b><br/> <input type="checkbox" name="clista[]" value="adobe"> <b>Removed Adobe-Update</b><br/> <input type="checkbox" name="clista[]" value="Java"> <b>Removed Java-Update</b><br/> <input type="checkbox" name="clista[]" value="msconfig"> <b>Disable Programs in MSCONFIG</b><br/> <input type="checkbox" name="clista[]" value="hiddenfiles"> <b>Show Hidden Files</b><br/> <br/><b>Delete Temp Files</b><br/> <input type="checkbox" name="clista[]" value="7vista" onclick="toggle(this,'7vista')"> <b>Vista/7</b> <input type="checkbox" name="clista[]" value="XP/9x" onclick="toggle(this,'XP')"> <b>XP/9x</b><br/> <div id="7vista" style="display: none;"> <input type="checkbox" name="clista[]" value="7 vista temp"> <b>C:\Users\*user name*\appdata\local\temp</b><br/> <input type="checkbox" name="clista[]" value="7 vista temp"> <b>C:\Temp (if applicable)</b><br/> <input type="checkbox" name="clista[]" value="7 vista temp"> <b>C:\Windows\Temp</b><br/> </div> <div id="XP" style="display: none;"> <input type="checkbox" name="clista[]" value="XP Temp"> <b>C:\Documents and Settings\*user name*\Local Settings\Temp</b><br/> <input type="checkbox" name="clista[]" value="XP Temp"> <b>C:\Temp (if applicable)</b><br/> <input type="checkbox" name="clista[]" value="XP Temp"> <b>C:\Windows\Temp</b><br/> </div> <br/><b>Delete Browser Data</b><br/> <input type="checkbox" name="clista[]" value="IE"> <b>Internet Explorer</b><br/> <input type="checkbox" name="clista[]" value="Firefox"> <b>Firefox</b><br/> <input type="checkbox" name="clista[]" value="Chrome"> <b>Chrome</b><br/> <input type="checkbox" name="clista[]" value="bother"> <b>Other</b><br/> <br/><input type="checkbox" name="clista[]" value="winupdate"> <b>Install Windows Updates</b><br/> <input type="checkbox" name="clista[]" value="install"> <b>Install Anti-Virus/Java/Adobe/anything else</b><br/> <input type="checkbox" name="clista[]" value="malware"> <b>Install & Run Anti-Malware</b> <b># of Infections</b><input type="text" size="3" name="malinfect" value=<?=($ticket->getmalinfect())?>><br/> <input type="checkbox" name="clista[]" value="restore"> <b>Delete Restore Points</b><br/> <input type="checkbox" name="clista[]" value="recycle"> <b>Empty Recycle Bin</b><br/> <input type="checkbox" name="clista[]" value="defrag"> <b>Defrag</b><br/> <input type="checkbox" name="clista[]" value="winupdate"> <b>Update Ticket With All Info!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</b><br/><br/> <input class="button" type="submit" value="Update"> </div> </form> </tr></td> </table> )And this is the current state of my processing code: PHP Code:
Now this is not complete (prolly not even right) and includes some stuff i tried to no avail. right now i would be happy to get the data to the database, i can tackle exploding it after that (one step at a time )If anybody knows a better way to get this data in the database (or the right way) let me know! If you need more info, i'm happy to help you help me! Last edited by jbartlett323; 04-03-2012 at 04:28 PM. |
|
#2
|
|||
|
|||
|
Bump!!
69 views and no answers. Can somebody tell me that they don't know, at least??
|
|
#3
|
|||
|
|||
|
Quote:
Hey! I can do that! Wish I could help, but I'm a newbie at OSTicket and coding too. My last batch file was made to check machines for Y2k compliance .
|
|
#4
|
|||
|
|||
|
Quote:
Yeah i know most on here are in the same boat, doesn't seem like too many coders on this board anymore. I would take it to a more code oriented site, but I don't want to have to write a 12 page dissertation to explain how osticket works and how what i'm trying to do is supposed to work in my mind.... Well the search continues!!! Any input is appreciated!! (yes, any input!! )
|
|
#5
|
|||
|
|||
|
ok, so every time i work on this I understand a bit more about osticket. this is a complex program for a newbie!! I love it!!
Anyway, I have found that when I created the 'update2' section in class.ticket.php (mentioned, however not expanded upon earlier) I removed a bit that wasn't supposed to come out in an attempt to get more than ' ' in my database. well it worked, kinda. I got 'clist' instead. just figured this out, so now i'm back to ' '. Heres the code if it helps anyone: PHP Code:
I think this kinda points to my problem though... I think somewhere in osticket it is stripping stuff from the string before it hits the database. I understand there is a good reason for this behavior (sql injection attacks) but I gotta get around it. So perhaps someone has had a similar problem of getting data to the database and they would share a work around? It would be greatly appreciated. Also i searched before, and at least one other person wanted to do something similar. So if anything in here can help the community, i'm all about it! might try to make this a bit more reader friendly after I figure it out... |
|
#6
|
|||
|
|||
|
ok, partly an update, partly a bump:
think i'm narrowing the issue... If i put in just a standard text box, i can add to and edited the data in the clist field. I think this might point me to an issue: the implode is happening at the same time its trying to update the database with the imploded data, therefore only capturing a "" input cause it isn't done processing till after... I dont know... kinda grasping at straws... |
|
#7
|
|||
|
|||
|
ok, so after trying this, that, and the other thing, i have figured out how this works!!!
Start with adding Variables as described in previous post, changing "type" to "text". Build your checkbox form on the viewticket.inc.php page. I put mine right below the "action" section (where you close tickets and change priority etc.) and added a small piece of jscript to hide/show it. Heres mine for reference: HTML Code:
<script type="text/javascript"> function toggle(chkbox, group) { var visSetting = (chkbox.checked) ? "block" : "none"; document.getElementById(group).style.display = visSetting; } </script> <table id='checklists'> <tr><td> <b>Tune-Up</b> <input type="checkbox" name="list" value="Tune-Up" onclick="toggle(this,'tuneup')" /> <b>OS Load</b> <input type="checkbox" name="list" value="OS Load" /> <b>Data Transfer</b> <input type="checkbox" name="list" value="Data Transfer" /> </tr></td> <tr><td><div id="tuneup" style="display: none;"> <form name="tunelist" action='tickets.php?id=<?=$id?>' method="post"> <input type='hidden' name='a' value="clistimport"/> <br/><input type="checkbox" name='clist[]' value='hdd' <?php if($clist[] == 'hdd'){echo 'checked="checked"';}?>> <b>HDD Diag</b><br/> <input type="checkbox" name='clist[]' value='antiv' <?php if($clist[] == 'antiv'){echo 'checked="checked"';}?>> <b>Check Anti-Virus</b><br/> <input type="checkbox" name="clist[]" value="excessprograms"> <b>Remove Excess Programs</b><br/> <input type="checkbox" name="clist[]" value="adobe"> <b>Removed Adobe-Update</b><br/> <input type="checkbox" name="clist[]" value="Java"> <b>Removed Java-Update</b><br/> <input type="checkbox" name="clist[]" value="msconfig"> <b>Disable Programs in MSCONFIG</b><br/> <input type="checkbox" name="clist[]" value="hiddenfiles"> <b>Show Hidden Files</b><br/> <br/><b>Delete Temp Files</b><br/> <input type="checkbox" name="clist[]" value="7vista" onclick="toggle(this,'7vista')"> <b>Vista/7</b> <input type="checkbox" name="clist[]" value="XP/9x" onclick="toggle(this,'XP')"> <b>XP/9x</b><br/> <div id="7vista" style="display: none;"> <input type="checkbox" name="clist[]" value="7 vista temp"> <b>C:\Users\*user name*\appdata\local\temp</b><br/> <input type="checkbox" name="clist[]" value="7 vista temp"> <b>C:\Temp (if applicable)</b><br/> <input type="checkbox" name="clist[]" value="7 vista temp"> <b>C:\Windows\Temp</b><br/> </div> <div id="XP" style="display: none;"> <input type="checkbox" name="clist[]" value="XP Temp"> <b>C:\Documents and Settings\*user name*\Local Settings\Temp</b><br/> <input type="checkbox" name="clist[]" value="XP Temp"> <b>C:\Temp (if applicable)</b><br/> <input type="checkbox" name="clist[]" value="XP Temp"> <b>C:\Windows\Temp</b><br/> </div> <br/><b>Delete Browser Data</b><br/> <input type="checkbox" name="clist[]" value="IE"> <b>Internet Explorer</b><br/> <input type="checkbox" name="clist[]" value="Firefox"> <b>Firefox</b><br/> <input type="checkbox" name="clist[]" value="Chrome"> <b>Chrome</b><br/> <input type="checkbox" name="clist[]" value="bother"> <b>Other</b><br/> <br/><input type="checkbox" name="clist[]" value="winupdate"> <b>Install Windows Updates</b><br/> <input type="checkbox" name="clist[]" value="install"> <b>Install Anti-Virus/Java/Adobe/anything else</b><br/> <input type="checkbox" name="clist[]" value="malware"> <b>Install & Run Anti-Malware</b> <b># of Infections</b><input type="text" size="3" name="malinfect" value=<?=($ticket->getmalinfect())?>><br/> <input type="checkbox" name="clist[]" value="restore"> <b>Delete Restore Points</b><br/> <input type="checkbox" name="clist[]" value="recycle"> <b>Empty Recycle Bin</b><br/> <input type="checkbox" name="clist[]" value="defrag"> <b>Defrag</b><br/> <input type="checkbox" name="clist[]" value="winupdate"> <b>Update Ticket With All Info!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</b><br/><br/> <input class="button" type="submit" value="Update"> </div> </form> </tr></td> </table> To get the data to the database, we must first Implode the clist[] array to a single string. to do this, i found that i had to create a new function to handle this then pass to a modified "update" function. So on the scp/tickets.php i added this: PHP Code:
This bit of code tells it first to implode, then continue to 'update2' (which is nearly identical to 'update', however i removed the line about 'editticket.inc.php' so it doesn't try to update everything!). 'Update2' (just like 'update') sends this info to the class.ticket.php function 'update2'! So on class.ticket.php (where you added most of the variable stuff) you need to copy 'function update' and create 'function update2' which should look like this: PHP Code:
Ok, so provided you created a column in your ost_ticket database called clist (or your variable name) with default values and "Text" type, this should work... maybe! To get the data back from the database is significantly easier... all you need to do on you viewticket.inc.php page is add the variable: $clist = explode(',',$ticket->getclist()); Now you data will come back! However this is where i once again run into problems: to get my checkboxes to check, the array has to be in the correct order. so i need to make sure that all checkboxes have a values to put in the database. I have looked at for, foreach, and other loops, but i dont know how to use them and deciphering them is tough when trying to apply it to this complex code... Anybody know the easiest way for me to do what i want? If not i'll post it when i figure it out.... EDIT: Ah! I got it! just add: PHP Code:
Hope this helps someone in the future! Last edited by jbartlett323; 04-03-2012 at 05:41 PM. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|