Insert ticket in Support Suite using CodeIgniter

   // Insert the Actual Record
        $ticket_data=array(
            'ticketid'=>'',
            'ticketmaskid'=>$ticketmaskid ,
            'departmentid'=>1 ,
            'ticketstatusid'=>1 ,
            'priorityid'=> 1,
            'emailqueueid'=>0 ,
            'userid'=>68 ,
            'staffid'=>2,
            'ownerstaffid'=>2,
            'assignstatus'=>1,
            'fullname'=>'someva' ,
            'email'=>$user_details['email'] ,
            'lastreplier'=>'someva' ,
            'replyto'=>$user_details['email'] ,
            'subject'=>'New Account is registered' ,
            'dateline'=>now() ,
            'lastactivity'=>now() ,
            'laststaffreplytime'=>now() ,
            'slaplanid'=>1 ,
            'duetime'=>0 ,
            'totalreplies'=>0 ,
            'ipaddress'=>'' ,
            'flagtype'=> 0,
            'hasnotes'=> 0,
            'hasattachments'=> 0,
            'isemailed'=> 0,
            'edited'=> 0,
            'editedbystaffid'=> 0,
            'editeddateline'=> 0,
            'creator'=> 1,
            'charset'=>'UTF-8' ,
            'transferencoding'=>'' ,
            'timeworked' =>0 ,
            'dateicon' =>0,
            'lastpostid'=>0,
            'firstpostid'=>0,
            'tgroupid'=>1 ,
            'messageid' =>$messageid ,
            'escalationruleid'=>0 ,
            'hasdraft'=>0 ,
            'hasbilling' =>0 ,
            'isphonecall' =>0 ,
            'isescalated'=>0 ,
            'phoneno'=>'' ,
            'autoclosetimeline' =>0 ,
            'islabeled' =>0 ,
            'lastuserreplytime' => now(),
            'escalatedtime' =>0 ,
            'followupcount'=>0 );
 
        $this->db1->insert('swtickets',$ticket_data);
        $ticketid=$this->db1->insert_id();
 
        $content="<p>Hi,</p>";
        $content.="<p>New account is registered with following details:</p>";
        $content.="<p> Full Name: ".$user_details['first_name']." ".$user_details['last_name'];
        $content.="</p><p> Email: ".$user_details['email']." </p>";
        $content.="<p> ".$this->get_orders()." </p>";
        $content.="<p></p>";
 
        $post_data=array(
            'ticketpostid'=>'' ,
            'ticketid'=>$ticketid ,
            'dateline'=>now() ,
            'userid'=>68 ,
            'fullname'=> 'someva',
            'email'=>$user_details['email'] ,
            'emailto'=>'' ,
            'subject'=>'New Account Registration' ,
            'ipaddress'=>'' ,
            'hasattachments'=>0 ,
            'edited'=>0 ,
            'editedbystaffid'=>0 ,
            'editeddateline'=>0 ,
            'creator'=>1 ,
            'ishtml'=>1 ,
            'isemailed'=>0 ,
            'staffid'=>2 ,
            'contents'=> $content,
            'contenthash'=>md5($content) ,
            'subjecthash'=>md5('New Account Registration')
        );
 
        $this->db1->insert('swticketposts',$post_data);
        $ticketpostid=$this->db1->insert_id();
 
 
 
        $ticket_message_data=array(
            'ticketmessageid'=>'',
            'messageid'=>$messageid ,
            'ticketid'=>$ticketid ,
            'ticketpostid'=>$ticketpostid ,
            'dateline' => now());
 
        $this->db1->insert('swticketmessageids',$ticket_message_data);
        $ticketmessageid=$this->db1->insert_id();
 
        //load default database
        $this->ci->load->database('default', TRUE);

Dependent functions

 /**
     * Generates a Random Message ID
     */
    function generateRandomMessageID()
    {
        srand((double)microtime()*10000000);
        $messageid = base_convert(time(), 10, 36).".". base_convert(rand(), 10, 36);
        return $messageid;
 
    }
    /**
     * Generate a random Ticket Mask
     */
    function generateTicketMask()
    {
 
    //        $id=100;
        do
        {
 
            $prefix = strtoupper(chr(mt_rand(65,90)) . chr(mt_rand(65,90)) . chr(mt_rand(65,90)));
 
            $ticketmaskid = $prefix . "-" . mt_rand(100000,999999);
            //$_maskcheck =
 
            $query = $this->ci->db->get_where('swtickets', array('ticketmaskid' => $ticketmaskid));
            //ticketmaskid FROM '". TABLE_PREFIX ."' WHERE '' = '". $dbCore->escape() ."';");
            $id=$this->ci->db->count_all();
 
        } while ($id!=0);
 
        return $ticketmaskid;
 
    }

Popularity: 58% [?]

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks

Leave a Reply