EC: Creates an E-ticket product. Dependencies: product.module/cart.module'); case 'node/add/product#eticket': return t('Sell E-tickets on site. When user checks out, details for each are entered and saved to database'); } } /** * Implementation of hook_perm(). */ function eticket_perm() { return array('create E-ticket products', 'edit own E-ticket products'); } /** * Implementation of hook_access(). */ function eticket_access($op, $node) { global $user; if ($op == 'create') { return user_access('create E-ticket products'); } if ($op == 'update' || $op == 'delete') { if (user_access('edit own E-ticket products') && ($user->uid == $node->uid)) { return TRUE; } } } /** * implementation of hook_settings() */ function eticket_ec_settings() { $form['eticket'] = array('#value' => '
'); return $form; } /** * Implementation of menu_hook() */ function eticket_menu($may_cache) { $items = array(); $items[] = array('path' => 'guestlist', 'title' => t('Guestlist'), 'callback' => '_eticket_guestlist_page', 'access' => user_access('administer users'), 'type' => MENU_CALLBACK); return $items; } /** * Implementation of productapi_hook() */ function eticket_productapi(&$node, $op, $a3 = null, $a4 = null) { switch ($op) { case 'fields': return array('stock' => $node->stock, 'manage_stock' => $node->manage_stock, 'availability' => $node->availability); case 'validate': if (isset($node->stock) && !$node->stock) { if (!$node->stock) { $node->stock = 0; } if (!is_numeric($node->stock)) { form_set_error('stock', t('Please enter a numeric value for stock.')); } } break; case 'wizard_select': return array('eticket' => t('E-ticket product')); case 'attributes': $attributes = array(); if (($node->manage_stock && $node->stock > 0) || !$node->manage_stock) { $attributes[] = 'in_stock'; } return $attributes; break; case 'cart add item': if ($node->manage_stock && $node->stock <= 0) { drupal_set_message(t('Tickets are sold out.'), 'error'); return FALSE; } break; case 'on payment completion': if ($node->manage_stock) { db_query('UPDATE {ec_product_tangible} SET stock = %d WHERE nid = %d', $node->stock - $node->qty, $node->nid); } break; case 'form': $form['inventory'] = array( '#type' => 'fieldset', '#title' => t("Ticket availablitiy control"), ); $form['inventory']['manage_stock'] = array( '#type' => 'radios', '#title' => t('Ticket availablitity management for this item'), '#default_value' => (($node->manage_stock == 0) ? $node->manage_stock : 1), '#options' => array(t('Disabled'), t('Enabled')), '#description' => t("When enabled, only a certain number of tickets are available. When tickets sell out, the 'Add to cart' will be replaced with 'Sold out'."), ); $form['inventory']["stock"] = array( '#type' => 'textfield', '#title' => t("Number of tickets"), '#default_value' => (($node->stock != '') ? $node->stock : 0), '#size' => 25, '#maxlength' => 50, '#description' => t("Total number of tickets for sale."), ); return $form; case 'load': return db_fetch_object(db_query('SELECT * FROM {ec_product_tangible} WHERE vid = %d', $node->vid)); case 'insert': return db_query("INSERT INTO {ec_product_tangible} (nid, vid, stock, manage_stock, availability) VALUES ('%d', '%d', '%d', '%d', '%s')", $node->nid, $node->vid, $node->stock, $node->manage_stock, $node->availability); case 'update': return db_query("UPDATE {ec_product_tangible} SET stock = '%d', manage_stock = '%d', availability = '%s' WHERE vid = '%d'", $node->stock, $node->manage_stock, $node->availability, $node->vid); case 'delete': return db_query('DELETE FROM {ec_product_tangible} WHERE nid = %d', $node->nid); } } /** * Implementation of hook_checkoutapi(). */ function eticket_checkoutapi(&$txn, $op, $post_op = NULL, $arg4 = NULL) { switch ($op) { case 'form': foreach ((array)$txn->items as $product) { $node = node_load($product->nid); if ($node->ptype == 'eticket') { for ($i = 1; $i <= $product->qty; $i++) { $form['eticket'.$i] = array( '#type' => 'fieldset', '#title' => t('Ticket Details '. $i), '#tree' => TRUE); if ($i == 1) { $form['eticket1']['info1'] = array('#value' => 'These details will be used as the main ticket holder. Confirmation details will be sent to this person'); } $form['eticket'.$i]['firstname'.$i] = array( '#type' => 'textfield', '#title' => t('Firstname'), '#default_value' => '', '#size' => 30, '#maxlength' => 64, '#required' => true, '#description' => t('Please enter the first name of the ticket holder')); $form['eticket'.$i]['surname'.$i] = array( '#type' => 'textfield', '#title' => t('Surname'), '#default_value' => '', '#size' => 30, '#maxlength' => 64, '#required' => true, '#description' => t('Please enter the surname of the ticket holder. This will be used on guestlist at door to get into party. ID may be required!')); $form['eticket'.$i]['email'.$i] = array( '#type' => 'textfield', '#title' => t('E-mail address'), '#default_value' => '', '#size' => 30, '#maxlength' => 64, '#required' => true, '#description' => t('Please enter the e-mail address of the ticket holder. Double-check to make sure the email address is correct!!| Firstname | Surname | Gender | ||
|---|---|---|---|---|
| ' . $firstname . ' | ' ); $form['eticketreview'][surname.$i] = array( '#value' => '' . $surname . ' | ' ); $form['eticketreview'][email.$i] = array( '#value' => '' . $email . ' | ' ); $form['eticketreview'][gender.$i] = array( '#value' => '' . $gender . ' | ' ); $form['eticketreview'][rowend.$i] = array( '#value' => '
| ' . l('Eticket #', 'guestlist', null, 'sortby=etid') . ' | ' . l('Surname', 'guestlist', null, 'sortby=lastname') . ' | ' . l('Firstname', 'guestlist', null, 'sortby=firstname') . ' | ' . l('Gender', 'guestlist', null, 'sortby=gender') . ' | ' . l('E-mail', 'guestlist', null, 'sortby=email') . ' |
|---|---|---|---|---|
| ' . $eticket->etid . ' | ' . $eticket->lastname . ' | ' . $eticket->firstname . ' | ' .$eticket->gender . ' | ' . $eticket->email . ' |
E-mail List:
'; if($emails) { foreach($emails as $email) { $output .= $email . '; '; } } return $output; } /** * Send confirmation e-mail to user */ function _eticket_send_email($txnemail, $txnid) { $result = db_query("select * from {ec_eticket_details} where txnid = '%d' order by lastname", $txnid); $msg = "Thankyou for purchasing your tickets for the Pimps & Hoes Bling Bling Party on Saturday, 10th February\n"; $msg .= "This e-mail is confirmation of your ticket details:\n\n"; $msg .= " TICKET # SURNAME FIRSTNAME GENDER E-MAIL\n"; while ($eticket = db_fetch_object($result)) { $msg .= " " . $eticket->etid . " " . $eticket->lastname . " " . $eticket->firstname . " " . $eticket->gender . " " . $eticket->email . "\n"; } $msg .= "\nPlease reply to us on this address (admin@pimpsandhoessociety.org.uk) If there are any problems with these details asap."; $mail['from'] = ''; $mail['to'] = $txnemail; $mail['subject'] = 'ETicket Confirmation'; $mail['body'] = $msg; $mail['type'] = 'txt'; ec_mail_send_mail($mail); //store_email_send('admin@pimpsandhoessociety.org.uk', $txnemail, 'P&H Bling Bling Party Ticket Confirmation', $msg); } ?>