/** * Builds a hidden form to submit the order to PayPal * * @author Jonathan Davis * @since 1.0 * * @param ShoppPurchase $Purchase The order to submit to PayPal * @return string PayPal order form contents **/ public function form(ShoppPurchase $Purchase) { $Shopping = ShoppShopping(); $Order = ShoppOrder(); $Cart = $Order->Cart; $Customer = $Order->Customer; $_ = array(); $_['cmd'] = '_cart'; $_['upload'] = 1; $_['business'] = $this->settings['account']; $_['invoice'] = $Purchase->id; $_['custom'] = $Shopping->session; // Options if (Shopp::str_true($this->settings['pdtverify'])) { $_['return'] = apply_filters('shopp_paypalstandard_returnurl', Shopp::url(array('rmtpay' => $this->id(), 'utm_nooverride' => '1'), 'checkout', false)); } else { $_['return'] = Shopp::url(false, 'thanks'); } $_['cancel_return'] = Shopp::url(false, 'cart'); $_['notify_url'] = $this->ipnurl(); $_['rm'] = 1; // Return with no transaction data // Pre-populate PayPal Checkout $_['lc'] = $this->baseop['country']; $_['charset'] = 'utf-8'; $_['bn'] = 'shopplugin.net[WPS]'; $_['first_name'] = $Customer->firstname; $_['last_name'] = $Customer->lastname; $AddressType = 'Shipping'; // Disable shipping fields if no shipped items in cart if (empty($Order->Cart->shipped)) { $AddressType = 'Billing'; $_['no_shipping'] = 1; } $Address = $Order->{$AddressType}; if (!empty($Order->Cart->shipped)) { $shipname = explode(' ', $Address->name); $_['first_name'] = array_shift($shipname); $_['last_name'] = join(' ', $shipname); } $_['address_override'] = 1; $_['address1'] = $Address->address; if (!empty($Address->xaddress)) { $_['address2'] = $Address->xaddress; } $_['city'] = $Address->city; $_['state'] = $Address->state; $_['zip'] = $Address->postcode; $_['country'] = $Address->country; $_['email'] = $Customer->email; $phone = parse_phone($Order->Customer->phone); if (!empty($phone) && in_array($Order->Billing->country, array('US', 'CA'))) { $_['night_phone_a'] = $phone['area']; $_['night_phone_b'] = $phone['prefix']; $_['night_phone_c'] = $phone['exchange']; } else { $_['night_phone_b'] = $phone['raw']; } // Include page style option, if provided if (isset($_GET['pagestyle'])) { $_['pagestyle'] = $_GET['pagestyle']; } // Transaction $_['currency_code'] = $this->currency(); // Recurring Non-Free Item $Cart->recurring(); $Subscription = reset($Cart->recurring); if ($Cart->recurring() && $Subscription->unitprice > 0) { $tranges = array('D' => array('min' => 1, 'max' => 90), 'W' => array('min' => 1, 'max' => 52), 'M' => array('min' => 1, 'max' => 24), 'Y' => array('min' => 1, 'max' => 5)); $recurring = $Subscription->recurring(); $recurring['period'] = strtoupper($recurring['period']); //normalize recurring interval $recurring['interval'] = min(max($recurring['interval'], $tranges[$recurring['period']]['min']), $tranges[$recurring['period']]['max']); $_['cmd'] = '_xclick-subscriptions'; $_['rm'] = 2; // Return with transaction data $_['item_number'] = $Subscription->product; $_['item_name'] = $Subscription->name . (!empty($Subscription->option->label) ? ' (' . $Subscription->option->label . ')' : ''); $trial_discounts = apply_filters('shopp_paypalstandard_discount_trials', false); // Trial pricing if ($Subscription->has_trial()) { $trial = $Subscription->trial(); $trial['period'] = strtoupper($trial['period']); $trialprice = $this->amount($trial['price']); if ($this->amount('discount') > 0 && $trial_discounts) { $trialprice -= $this->amount('discount'); } // normalize trial interval $trial['interval'] = min(max($trial['interval'], $tranges[$trial['period']]['min']), $tranges[$trial['period']]['max']); $_['a1'] = $this->amount($trial['price']); $_['p1'] = $trial['interval']; $_['t1'] = $trial['period']; } elseif ($this->amount('discount') > 0 && $trial_discounts) { // When no trial discounts are created, add a discount to a trial offer using // the interval and period of the normal subscription, but at a discounted price $_['a1'] = $this->amount($Subscription->subprice) - $this->amount('discount'); $_['p1'] = $recurring['interval']; $_['t1'] = $recurring['period']; } $subprice = $this->amount($Subscription->subprice); if ($this->amount('discount') > 0 && !$trial_discounts) { $subprice -= $this->amount('discount'); } $_['a3'] = $subprice; $_['p3'] = $recurring['interval']; $_['t3'] = $recurring['period']; $_['src'] = 1; if ($recurring['cycles']) { $_['srt'] = (int) $recurring['cycles']; } } else { // Line Items $id = 0; foreach ($Order->Cart as $i => $Item) { $id++; $_['item_number_' . $id] = $id; $_['item_name_' . $id] = $Item->name . (!empty($Item->option->label) ? ' ' . $Item->option->label : ''); $_['amount_' . $id] = $this->amount($Item->unitprice); $_['quantity_' . $id] = $Item->quantity; // $_['weight_'.$id] = $Item->quantity; } // Workaround a PayPal limitation of not correctly handling no subtotals or // handling discounts in the amount of the item subtotals by adding the // shipping fee to the line items to get included in the subtotal. If no // shipping fee is available use 0.01 to satisfy minimum order amount requirements // Additionally, this condition should only be possible when using the shopp('cart','paypal') // Theme API tag which would circumvent normal checkout and use PayPal even for free orders if ((double) $this->amount('order') == 0 || (double) $this->amount('order') - (double) $this->amount('discount') == 0) { $id++; $_['item_number_' . $id] = $id; $_['item_name_' . $id] = apply_filters('paypal_freeorder_handling_label', __('Shipping & Handling', 'Shopp')); $_['amount_' . $id] = $this->amount(max((double) $this->amount('shipping'), 0.01)); $_['quantity_' . $id] = 1; } else { $_['handling_cart'] = $this->amount('shipping'); } $_['discount_amount_cart'] = $this->amount('discount'); $_['tax_cart'] = $this->amount('tax'); $_['amount'] = $this->amount('total'); } $_ = apply_filters('shopp_paypal_standard_form', $_); return $this->format($_); }
} // Initialize values! $name = ''; $phone = ''; $year = ''; $month = ''; $day = ''; $desc = ''; $checked = ''; $id = isset($_GET['id']) ? $_GET['id'] : null; if ($id) { $req = new Request(); $req->id = $id; $req->find(); $name = $req->name; $phone = parse_phone($req->phone); $y = substr($req->deadline, 0, 4); $m = substr($req->deadline, 5, 2); $d = substr($req->deadline, 8, 2); $time = strtotime("{$y}/{$m}/{$d}"); $year = '<option>' . date('Y', $time) . '</option>'; $month = '<option>' . date('F', $time) . '</option>'; $day = '<option>' . date('j', $time) . '</option>'; $desc = $req->description; $checked = $req->approved ? 'checked="checked"' : ''; //update size of textarea to fit description $row_size = 1 + strlen($desc) / 40; } ?> <!DOCTYPE html> <head>
$requestor_phone = parse_phone($req->phone); $deadline = $asn->complete; $description = $req->description; } else { if ($id) { $rec = new Record(); $rec->id = $id; $rec->find(); $asn = new Assign(); $asn->id = $rec->aid; $asn->find(); $req = new Request(); $req->id = $asn->rid; $req->find(); $requestor = $req->name; $requestor_phone = parse_phone($req->phone); $deadline = $asn->complete; $description = $req->description; $hours = $rec->hours; $materials = $rec->materials; $cost = '$' . $rec->cost; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Job Approval</title> <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript" src="jquery-1.7.min.js"></script>