Insert user fields

Started by cristianlf, January 14, 2011, 09:49:47 PM

Previous topic - Next topic

cristianlf

Hello friends,
I have a trouble in the office, my boss wants to add some fields to the ticket form and I added (at display level) but when I try to post the ticket i dont know how to add my fields into the insert function ??

I  mean I already add fields and tables to the Database, and just need to add some fields to the insert of new Tickets
well if you can help me pleaaase, this has to be done to monday :S

by the way i want to ask where is $context[] defined ??

regards

Spoogs

One of the devs maybe able to help you with this... in the mean time I'd like to point out that custom fields are 1 of the features that will be rolled out with the 1.1 release.

Francis

Hi,

Inserting of the tickets is done in Sources\SimpleDesk-Post.php. The very first function contains the parameters to insert in the database, if I remember correctly. $context is defined there as well.

chilly

$context[] it a variable created by smf with global use through all of smf's code. (if that was the question)
got a cookie for me?

cristianlf

Thaks but the answers,

i will see Sources\SimpleDesk-Post.php

i will comment in a short time ...

regards,


cσσкιє мσηѕтєя

The files you'll need to look in are:

SimpleDesk-Post.php
Subs-SimpleDesk-Post.php
SimpleDesk-Display.php
SimpleDesk-Display.template.php
SimpleDesk-Post.template.php

cristianlf

Quote from: cσσкιє мσηѕтєя on January 15, 2011, 10:50:53 AM
The files you'll need to look in are:

SimpleDesk-Post.php
Subs-SimpleDesk-Post.php
SimpleDesk-Display.php
SimpleDesk-Display.template.php
SimpleDesk-Post.template.php

Thanks :)  i will let you know

Gruffen

There's also 6 separate functions you'll have to modify, which is basically every place that $context['ticket_form'] is created.

Francis

Quote from: Gruffen on January 16, 2011, 06:04:39 AM
There's also 6 separate functions you'll have to modify, which is basically every place that $context['ticket_form'] is created.
Well actually, these functions are in the files listed above by Cookie Monster.

cristianlf

Thanks for the help, 

I need to add my variables in here

   $context['ticket_form'] = array( // yes, everything goes in here.
      'form_title' => $new_ticket ? $txt['shd_create_ticket'] : $txt['shd_edit_ticket'],
      'form_action' => $scripturl . '?action=helpdesk;sa=saveticket',
      'first_msg' => $new_ticket ? 0 : $ticketinfo['id_first_msg'],
      'message' => $new_ticket ? '' : $ticketinfo['body'],
      'subject' => $new_ticket ? '' : $ticketinfo['subject'],
      'ticket' => $new_ticket ? 0 : $context['ticket_id'],
      'link' => $new_ticket ? 0 : '<a href="' . $scripturl . '?action=helpdesk;sa=ticket;ticket=' . $context['ticket_id'] . '">' . $ticketinfo['subject'] . '</a>',
      'msg' => $new_ticket ? 0 : $ticketinfo['id_first_msg'],
      'display_id' => $new_ticket ? '' : str_pad($context['ticket_id'], 5, '0', STR_PAD_LEFT),
      'status' => $new_ticket ? TICKET_STATUS_NEW : $ticketinfo['status'],
      'urgency' => array(
         'setting' => $new_ticket ? TICKET_URGENCY_LOW : $ticketinfo['urgency'],
      ),
      'private' => array(
         'setting' => $new_ticket ? false : ($ticketinfo['private'] == 1),
         'can_change' => shd_allowed_to('shd_alter_privacy_any') || (shd_allowed_to('shd_alter_privacy_own') && ($new_ticket || !empty($ticketinfo['is_own']))),
         'options' => array(
            0 => 'shd_ticket_notprivate',
            1 => 'shd_ticket_private',
         ),
      ),
      'errors' => array(),
      'num_replies' => $new_ticket ? 0 : $ticketinfo['num_replies'],
      'do_attach' => shd_allowed_to('shd_post_attachment'),
      'num_allowed_attachments' => empty($modSettings['attachmentNumPerPostLimit']) || $modSettings['shd_attachments_mode'] == 'ticket' ? -1 : $modSettings['attachmentNumPerPostLimit'],
      'return_to_ticket' => isset($_REQUEST['goback']),
      'disable_smileys' => $new_ticket ? !empty($_REQUEST['no_smileys']) : ($ticketinfo['smileys_enabled'] == 0),
   );


is correct?

but then I need to add and something to  ->  $ticketinfo
$newticket ? 0 : $ticket['myvariables']   

then I was seeing the $smcFunc['db_query']($identifier, $db_string, $db_values, $connection) but i dont get it quite well.

I was tryng (just as a debugging) to get the variables i made with $_REQUEST['myvariables'] bt I cant write the result using javacript alert  ....   

I ll keep trying doing the way you are sugesting, please if you could give me some more guidline .... 

Regards

Francis

Use PHP to do:
<?php echo '<script type="text/javascript">alert("' $_REQUEST['myvariables'] . '");<script>'?>
Or maybe -
<?php echo '<script type="text/javascript">alert("' print_r($_REQUEST) . '");<script>'?>

I don't get what fields you want to add, what would they be?

cristianlf

well i need to add 5 fields, that will be related and the user need to select, besides the  options will be store in the DB ... 


cristianlf

Hello guys!!

Well I reaaly try to use shd_ functions to insert the data but ... 

I finaly do this .:

@ SimpleDesk-Post.php
     @shd_save_ticket()
                                        $context['Name_group_own_variables'] = array(
                                          'Variable 1' =>  $_POST['variable1'],
                                          'Variable 2' =>  $_POST['variable2']
                                          );

then
@ Subs-SimpleDeskPost.php
       @ shd_create_ticket_post
                          After if (empty($ticketOptions['id'])) {...}   I add te code:
                           else {
                                     $update ="update ....  ".
                                     "where id_ticket =".$ticketOptions['id'];
                           }
             

I know this is not the best way to do that  if you help me to get it better i'll apreciate it ,  I still need to display the values when someone see the ticket ... 

Well this was dificult to me, thanks every1 that helps me  someway ...

Regards

Gruffen

#13
Quote from: Francis on January 16, 2011, 11:04:51 AM
Quote from: Gruffen on January 16, 2011, 06:04:39 AM
There's also 6 separate functions you'll have to modify, which is basically every place that $context['ticket_form'] is created.
Well actually, these functions are in the files listed above by Cookie Monster.

Yes, I know that ;)

Putting it in shd_save_ticket() will make sure it's saved only when the ticket is edited or newly created (as opposed to on reply).

I would tried to help more but I can't help without knowing what fields you were trying to add, where you were trying to add them, etc. and the result is that it might well be a mess and/or do something unexpected... :/

cristianlf

No worries ...

I was trying to add 5  <selects>  that are dependant ... so I had to insert an js file in the header a then change the functions that I explained before,

well I just need to add now a validation because the fields are not optional,  and I still working on that ... if you have some sugestions please tell me about it :)

Regards