Ask not what osTicket community can do for you - ask what you can do for osTicket community

Go Back   osTicket Forums > osTicket 1.6.x > Mods and Customizations

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-30-2012, 09:00 AM
guyfonderball guyfonderball is offline
Junior Member
 
Join Date: Mar 2012
Posts: 13
Default No Tickets created after modification

Hi.

I have made a modification that calculates the date when a Ticket is overdue, based on actual workhours (meaning a ticket can't become overdue outside workhours) The first version was based on the assumption that tickets will only be created during workhours, due to using Autocron. (I hadn't bothered with a cronjob) This version worked like this:

class.ticket.php (starting line 1320):
PHP Code:
//Make sure the origin is staff - avoid firebug hack!
if($var['duedate'] && !strcasecmp($origin,'staff'))
    
$sql.=',duedate='.db_input(date('Y-m-d G:i',Misc::dbtime($var['duedate'].' '.$var['time'])));
elseif(!
strcasecmp($origin,'Email')) {
    
$Zeit = new Zeitberechnung('Schrott'); //don't ask -_-
    
$zuteilen time() + $Zeit->berechnen(); 
    
$var['duedate'] = date('d.m.Y'$zuteilen);
    
$var['time'] = date('G:i'$zuteilen);
    
$sql.=',duedate='.db_input(date('Y-m-d G:i',Misc::dbtime($var['duedate'].' '.$var['time'])));

The function berechnen() gives the amount of seconds to add to the current time.

Now, I wanted to alter the code in case a cronjob is set, so that the duedate will still be within workhours. To do this, I had to change the berechnen() function so it now returns the actual timestamp. (created by either the mktime() or strtotime() function) This worked without problems in a small testscript, but when I included the changes into osticket, (which also meant removing the 'time() + 'from the line where the function berechnen() is called) the system stopped creating Tickets. Any Idea what the problem is?
Reply With Quote
  #2  
Old 05-02-2012, 10:05 AM
guyfonderball guyfonderball is offline
Junior Member
 
Join Date: Mar 2012
Posts: 13
Default

Sorry for the double-Post, but i'm a bit on a schedule. To give some more information, i present the berechnen()-function:
PHP Code:
function berechnen(){
        global 
$cfg;
        
$Termin time(); //Termin = due date
        
$plusinterval $cfg->getGracePeriod(); //Helpvariable
        
if (date('G',$Termin) < 8) { //between 0:00 and 7:59
            
$Stunden=$plusinterval 8//8 = begin workhours
            
$Monat=date('n',$Termin);
            
$Tag=date('j',$Termin);
            
$Jahr=date('Y',$Termin);
            
$Termin mktime($Stunden,0,0,$Monat,$Tag,$Jahr);
        }elseif (
date('G',$Termin) + $plusinterval >= 17) {    //17= end workhours, this checks if the due date would be after workhours
            
if (date('G',$Termin) >= 17) { //between 17:00 and 23:59
                
$Stunden=$plusinterval 8;
                
$Minuten=0;
            }else { 
//Email arrived during workhours, but due date would be after
                
$Stunden date('G',$Termin) + ($plusinterval 9);    //don't ask how this works, it just does
                
$Minuten=date('i',$Termin);
            }
            
$pruefer false//for the while() loop. Propably not the best solution
            
$extratage 1;    //How many days have to be added to the current date
            
while (! $pruefer):
                if (
feiertag($Termin + ($extratage 24 60 60)) == '0'){ //this function returns 0 when the next day is a holiday or weekend.
                    
$extratage += 1;
                }
                else 
                    
$pruefer true;
            endwhile;
            
$Monat=date('n',$Termin);
            
$Tag=date('j',$Termin)+$extratage;
            
$Jahr=date('Y',$Termin);
            
$Termin mktime($Stunden,$Minuten,0,$Monat,$Tag,$Jahr);
        } else
            
$Termin strtotime('+'.$plusinterval.' hours',$Termin);
        return 
$Termin;
    } 
And before anyone asks, the feiertag()-function can't be the problem, since i used it in the previous version as well, and didn't change it.
Reply With Quote
  #3  
Old 05-03-2012, 12:05 PM
ntozier's Avatar
ntozier ntozier is offline
Moderator
 
Join Date: Jan 2010
Location: NH USA
Posts: 1,600
Default

Have you tried putting the stock class.ticket.php back in place to see if the system starts making tickets again?

Also I have moved this post to the mods forum since your problem is the result of modding your source.
Reply With Quote
  #4  
Old 05-04-2012, 05:20 AM
guyfonderball guyfonderball is offline
Junior Member
 
Join Date: Mar 2012
Posts: 13
Default

I still have the first Version of my modification, and that one is still working.
Reply With Quote
  #5  
Old 05-07-2012, 09:42 AM
guyfonderball guyfonderball is offline
Junior Member
 
Join Date: Mar 2012
Posts: 13
Default

It's getting more confusing. When I removed the call of the function berechnen() (basically having the content of the loop be $pruefer=true; ), the ticket creation was working again. When i changed the function berechnen() to just return '1', it still didn't work.

Edit: -_- Spot the difference:
PHP Code:
if (feiertag($Termin + ($extratage 24 60 60)) == '0'
PHP Code:
if ($this->feiertag($Termin + ($extratage 24 60 60)) == '0'
Now guess which Version works.

Yeah, you read right. I forgot the Object. ARGH!!!

On a lighter sidenote, should i manage to get some time free for it, i'll try to make the mod more complete (like including setting workhours in the config or something like that) and open a new thread for it.

Last edited by guyfonderball; 05-07-2012 at 01:24 PM.
Reply With Quote


Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:57 AM.