Post Admin name

Locked

Started by ink on 6 Jun 2006, 8:49 AM · Views: 5,547

Results 1 to 16 of 16
This thread is locked. New replies are disabled.
6 Jun 2006, 8:49 AM
#1
ink avatar

ink

Zen Follower

Join Date:
Jul 2004
Posts:
140
Plugin Contributions:
0

Post Admin name

Hi

How do I change the following code to post the actual 'admin_name' from the admin table into the 'sent_fistname' field in the coupon_email_track table?

I think this is the code to alter in the relevent file:

$db->Execute("insert into " . TABLE_COUPON_EMAIL_TRACK . "
(coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent)
values ('" . $insert_id ."', '0', 'Admin',
'" . $mail['customers_email_address'] . "', now() )");

Thanks.

7 Jun 2006, 1:30 AM
#2
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,714
Plugin Contributions:
0

Re: Post Admin name

What are you trying to accomplish?

Please do not PM for support issues: a private solution doesn't benefit the community.

Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

7 Jun 2006, 1:35 AM
#3
merlinpa1969 avatar

merlinpa1969

Totally Zenned

Join Date:
Mar 2004
Posts:
13,031
Plugin Contributions:
4

Re: Post Admin name

Looks like he wants to add

this coupon was sent curtesy of ( admin real name here )

Zen cart PCI compliant Hosting

7 Jun 2006, 3:30 AM
#4
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Post Admin name

The following bolded statement is the one you need to modify from your quote above:

$db->Execute("insert into " . TABLE_COUPON_EMAIL_TRACK . "
(coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent)
values ('" . $insert_id ."', '0', 'Admin',
'" . $mail['customers_email_address'] . "', now() )");

it should be changed into the existent string that actually gathers the sender's firstname. :wink2:

7 Jun 2006, 11:36 AM
#5
ink avatar

ink

Zen Follower

Join Date:
Jul 2004
Posts:
140
Plugin Contributions:
0

Re: Post Admin name

TheOracle:

The following bolded statement is the one you need to modify from your quote above:

it should be changed into the existent string that actually gathers the sender's firstname. :wink2:

I totally agree, what I want to substitute it with is, the detail of whatever the admin user who is logged in at the time is.

For example, say John who works for us, is logged in to the admin backend of the store sends a credit to a customer, it would show him as the sender on the report.

Hope you follow if not please feel free to let me know.

7 Jun 2006, 12:53 PM
#6
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Post Admin name

I thought ... it was already like that. :blink:

I'd sure be happy to make this modification. I will post the results shortly (if no one else post it before I do).

7 Jun 2006, 12:54 PM
#7
merlinpa1969 avatar

merlinpa1969

Totally Zenned

Join Date:
Mar 2004
Posts:
13,031
Plugin Contributions:
4

Re: Post Admin name

this is only hindered by the fact that unless you use your employees real names for usernames it could look rather funny.

Zen cart PCI compliant Hosting

7 Jun 2006, 1:13 PM
#8
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Post Admin name

Ok, let's try this out:

$db->Execute("insert into " . TABLE_COUPON_EMAIL_TRACK . "
(coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent)
values ('" . $insert_id ."', '0', 'Admin',
'" . $mail->fields['customers_email_address'] . "', now() )");

change to:

$db->Execute("insert into " . TABLE_COUPON_EMAIL_TRACK . "
                    (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent)
                    values ('" . $insert_id ."', '0', '".$from."',
                            '" . $mail->fields['customers_email_address'] . "', now() )");

After applying these modifications, it should show the current admin's email as result. :thumbsup:

Then, lower, change this block:

$insert_query = $db->Execute("insert into " . TABLE_COUPON_EMAIL_TRACK . "
(coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent)
values ('" . $insert_id ."', '0', 'Admin',
'" . $_POST['email_to'] . "', now() )");

to read:

$insert_query = $db->Execute("insert into " . TABLE_COUPON_EMAIL_TRACK . "
                                    (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent)
                                    values ('" . $insert_id ."', '0', '".$from."',
                                            '" . $_POST['email_to'] . "', now() )");

Note: Backup your file first.

7 Jun 2006, 2:29 PM
#9
ink avatar

ink

Zen Follower

Join Date:
Jul 2004
Posts:
140
Plugin Contributions:
0

Re: Post Admin name

Really appreciate your help Guys - I'm toatally lost on this one!

Unfortunately '$this' is not holding the required info. Are you sure that that is the variable holding the admin logged in users identity?

7 Jun 2006, 3:10 PM
#10
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Post Admin name

Unfortunately '$this' is not holding the required info. Are you sure that that is the variable holding the admin logged in users identity?

Unfortunitely, I cannot find any results on this topic where I mentionned anything about '$this'. I can only find: '$from'. Perhaps you saw another word when reading my last post. :wink2:

7 Jun 2006, 4:14 PM
#11
ink avatar

ink

Zen Follower

Join Date:
Jul 2004
Posts:
140
Plugin Contributions:
0

Re: Post Admin name

Sorry brains a bit adled from the sun today!! I meant '$from'. This is what I changed the code to with no avail:

			$db->Execute("insert into " . TABLE_COUPON_EMAIL_TRACK . "
							  (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent)
							  values ('" . $insert_id ."', '0', '".$from."',
										 '" . $mail['customers_email_address'] . "', now() )");

I wonder what variable it is that holds the logged in admin users name?

7 Jun 2006, 4:24 PM
#12
merlinpa1969 avatar

merlinpa1969

Totally Zenned

Join Date:
Mar 2004
Posts:
13,031
Plugin Contributions:
4

Re: Post Admin name

try this,
not tested

$db->Execute("insert into " . TABLE_COUPON_EMAIL_TRACK . "
(coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent)
values ('" . $insert_id ."', '0', '".$from."',
'" . $mail->fields['customers_email_address'] . "', now() )");

Zen cart PCI compliant Hosting

7 Jun 2006, 4:47 PM
#13
ink avatar

ink

Zen Follower

Join Date:
Jul 2004
Posts:
140
Plugin Contributions:
0

Re: Post Admin name

Hi Merlin

Thanks but I had already tried that suggestion earlier. is $from the only variable that holds the elusive admin users id?

7 Jun 2006, 5:27 PM
#14
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Post Admin name

How rude - I wasn't notified by email for these last two notes. :blink:

Anyway. Here's a modification I just coded while you were waiting (untested - so make a backup of the file first).

On that same file,

find:

$id1 = create_coupon_code($mail->fields['customers_email_address']);
$insert_query = $db->Execute("insert into " . TABLE_COUPONS . "
(coupon_code, coupon_type, coupon_amount, date_created)
values ('" . $id1 . "', 'G', '" . $_POST['amount'] . "', now())");

  $insert_id = $db->Insert_ID();

  $db->Execute("insert into " . TABLE_COUPON_EMAIL_TRACK . "
                (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent)
                values ('" . $insert_id ."', '0', 'Admin',
                        '" . $mail->fields['customers_email_address'] . "', now() )");

replace with:

$id1 = create_coupon_code($mail->fields['customers_email_address']);
      $insert_query = $db->Execute("insert into " . TABLE_COUPONS . "
                                    (coupon_code, coupon_type, coupon_amount, date_created)
                                    values ('" . $id1 . "', 'G', '" . $_POST['amount'] . "', now())");

      $insert_id = $db->Insert_ID();

      $mail_from = $db->Execute("select admin_name FROM ".TABLE_ADMIN." where admin_id = '".(int)$_SESSION['admin_id']."'");

      while (!$mail_from->EOF) {
      $sent_from = trim($mail_from->fields['admin_name']);

      $db->Execute("insert into " . TABLE_COUPON_EMAIL_TRACK . "
                    (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent)
                    values ('" . $insert_id ."', '0', '".$sent_from."',
                            '" . $mail->fields['customers_email_address'] . "', now() )");
      }

Then, a couple of lines below,

find:

$insert_query = $db->Execute("insert into " . TABLE_COUPONS . "
(coupon_code, coupon_type, coupon_amount, date_created)
values ('" . $id1 . "', 'G', '" . $_POST['amount'] . "', now())");

  $insert_id = $db->Insert_id();

  $insert_query = $db->Execute("insert into " . TABLE_COUPON_EMAIL_TRACK . "
                                (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent)
                                values ('" . $insert_id ."', '0', 'Admin',
                                        '" . $_POST['email_to'] . "', now() )");

}

replace with:

$mail_from = $db->Execute("select admin_name FROM ".TABLE_ADMIN." where admin_id = '".(int)$_SESSION['admin_id']."'");

      while (!$mail_from->EOF) {
      $sent_from = trim($mail_from->fields['admin_name']);

      $insert_query = $db->Execute("insert into " . TABLE_COUPON_EMAIL_TRACK . "
                                    (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent)
                                    values ('" . $insert_id ."', '0', '".$sent_from."',
                                            '" . $_POST['email_to'] . "', now() )");
      }

    }

Recall: Make a backup of the file, first, before you proceed. :wink2:

7 Jun 2006, 7:23 PM
#15
ink avatar

ink

Zen Follower

Join Date:
Jul 2004
Posts:
140
Plugin Contributions:
0

Re: Post Admin name

You've cracked it :) Thanks alot to both you and Merlin for your precious time on this

7 Jun 2006, 9:48 PM
#16
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Post Admin name

Excellent. Thanks for updating, Glad to see it worked out well for you. :thumbsup: