@@ -34,6 +34,10 @@ |
||
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | + /** |
|
| 38 | + * @param string $encrypted |
|
| 39 | + * @param string $decrypted |
|
| 40 | + */ |
|
| 37 | 41 | public function handleDataFeed($encrypted, $decrypted){ |
| 38 | 42 | //handle encrypted & decrypted data |
| 39 | 43 | $orders = new SimpleXMLElement($decrypted); |
@@ -10,15 +10,15 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | static $allowed_actions = array( |
| 12 | 12 | 'index', |
| 13 | - 'sso' |
|
| 13 | + 'sso' |
|
| 14 | 14 | ); |
| 15 | 15 | |
| 16 | 16 | public function index() { |
| 17 | - // handle POST from FoxyCart API transaction |
|
| 17 | + // handle POST from FoxyCart API transaction |
|
| 18 | 18 | if ((isset($_POST["FoxyData"]) OR isset($_POST['FoxySubscriptionData']))) { |
| 19 | 19 | $FoxyData_encrypted = (isset($_POST["FoxyData"])) ? |
| 20 | - urldecode($_POST["FoxyData"]) : |
|
| 21 | - urldecode($_POST["FoxySubscriptionData"]); |
|
| 20 | + urldecode($_POST["FoxyData"]) : |
|
| 21 | + urldecode($_POST["FoxySubscriptionData"]); |
|
| 22 | 22 | $FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::getStoreKey(),$FoxyData_encrypted); |
| 23 | 23 | self::handleDataFeed($FoxyData_encrypted, $FoxyData_decrypted); |
| 24 | 24 | |
@@ -35,200 +35,200 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | public function handleDataFeed($encrypted, $decrypted){ |
| 38 | - //handle encrypted & decrypted data |
|
| 39 | - $orders = new SimpleXMLElement($decrypted); |
|
| 38 | + //handle encrypted & decrypted data |
|
| 39 | + $orders = new SimpleXMLElement($decrypted); |
|
| 40 | 40 | |
| 41 | 41 | // loop over each transaction |
| 42 | - foreach ($orders->transactions->transaction as $order) { |
|
| 43 | - |
|
| 44 | - if(isset($order->id)) { |
|
| 45 | - ($transaction = Order::get()->filter('Order_ID', $order->id)->First()) ? |
|
| 46 | - $transaction : |
|
| 47 | - $transaction = Order::create(); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - // Record transaction data from FoxyCart Datafeed: |
|
| 51 | - $transaction->Order_ID = (int) $order->id; |
|
| 52 | - $transaction->Store_ID = (int) $order->store_id; |
|
| 53 | - $transaction->StoreVersion = (string) $order->store_version; |
|
| 54 | - $transaction->IsTest = (int) $order->is_test; |
|
| 55 | - $transaction->IsHidden = (int) $order->is_hidden; |
|
| 56 | - $transaction->DataIsFed = (int) $order->data_is_fed; |
|
| 57 | - $transaction->TransactionDate = (string) $order->transaction_date; |
|
| 58 | - $transaction->ProcessorResponse = (string) $order->processor_response; |
|
| 59 | - $transaction->ShiptoShippingServiceDescription = (string) $order->shipto_shipping_service_description; |
|
| 60 | - $transaction->ProductTotal = (float) $order->product_total; |
|
| 61 | - $transaction->TaxTotal = (float) $order->tax_total; |
|
| 62 | - $transaction->ShippingTotal = (float) $order->shipping_total; |
|
| 63 | - $transaction->OrderTotal = (float) $order->order_total; |
|
| 64 | - $transaction->PaymentGatewayType = (string) $order->payment_gateway_type; |
|
| 65 | - $transaction->ReceiptURL = (string) $order->receipt_url; |
|
| 66 | - $transaction->OrderStatus = (string) $order->status; |
|
| 67 | - $transaction->CustomerIP = (string) $order->customer_ip; |
|
| 68 | - $transaction->Response = $decrypted; |
|
| 69 | - |
|
| 70 | - // Customer info |
|
| 71 | - // if not a guest transaction in FoxyCart |
|
| 72 | - if(isset($order->customer_email) && $order->is_anonymous == 0) { |
|
| 73 | - |
|
| 74 | - // set PasswordEncryption to 'none' so imported, encrypted password is not encrypted again |
|
| 75 | - Config::inst()->update('Security', 'password_encryption_algorithm', 'none'); |
|
| 76 | - |
|
| 77 | - // if Customer is existing member, associate with current order |
|
| 78 | - ($customer = Member::get()->filter('Email', $order->customer_email)->First()) ? |
|
| 79 | - $customer : |
|
| 80 | - $customer = Member::create(); |
|
| 81 | - |
|
| 82 | - $customer->Customer_ID = (int) $order->customer_id; |
|
| 83 | - $customer->MinifraudScore = (string) $order->minifraud_score; |
|
| 84 | - $customer->FirstName = (string) $order->customer_first_name; |
|
| 85 | - $customer->Surname = (string) $order->customer_last_name; |
|
| 86 | - $customer->Email = (string) $order->customer_email; |
|
| 87 | - $customer->Password = (string) $order->customer_password; |
|
| 88 | - $customer->Salt = (string) $order->customer_password_salt; |
|
| 89 | - $customer->PasswordEncryption = 'none'; |
|
| 90 | - |
|
| 91 | - // record member record |
|
| 92 | - $customer->write(); |
|
| 42 | + foreach ($orders->transactions->transaction as $order) { |
|
| 43 | + |
|
| 44 | + if(isset($order->id)) { |
|
| 45 | + ($transaction = Order::get()->filter('Order_ID', $order->id)->First()) ? |
|
| 46 | + $transaction : |
|
| 47 | + $transaction = Order::create(); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + // Record transaction data from FoxyCart Datafeed: |
|
| 51 | + $transaction->Order_ID = (int) $order->id; |
|
| 52 | + $transaction->Store_ID = (int) $order->store_id; |
|
| 53 | + $transaction->StoreVersion = (string) $order->store_version; |
|
| 54 | + $transaction->IsTest = (int) $order->is_test; |
|
| 55 | + $transaction->IsHidden = (int) $order->is_hidden; |
|
| 56 | + $transaction->DataIsFed = (int) $order->data_is_fed; |
|
| 57 | + $transaction->TransactionDate = (string) $order->transaction_date; |
|
| 58 | + $transaction->ProcessorResponse = (string) $order->processor_response; |
|
| 59 | + $transaction->ShiptoShippingServiceDescription = (string) $order->shipto_shipping_service_description; |
|
| 60 | + $transaction->ProductTotal = (float) $order->product_total; |
|
| 61 | + $transaction->TaxTotal = (float) $order->tax_total; |
|
| 62 | + $transaction->ShippingTotal = (float) $order->shipping_total; |
|
| 63 | + $transaction->OrderTotal = (float) $order->order_total; |
|
| 64 | + $transaction->PaymentGatewayType = (string) $order->payment_gateway_type; |
|
| 65 | + $transaction->ReceiptURL = (string) $order->receipt_url; |
|
| 66 | + $transaction->OrderStatus = (string) $order->status; |
|
| 67 | + $transaction->CustomerIP = (string) $order->customer_ip; |
|
| 68 | + $transaction->Response = $decrypted; |
|
| 69 | + |
|
| 70 | + // Customer info |
|
| 71 | + // if not a guest transaction in FoxyCart |
|
| 72 | + if(isset($order->customer_email) && $order->is_anonymous == 0) { |
|
| 73 | + |
|
| 74 | + // set PasswordEncryption to 'none' so imported, encrypted password is not encrypted again |
|
| 75 | + Config::inst()->update('Security', 'password_encryption_algorithm', 'none'); |
|
| 76 | + |
|
| 77 | + // if Customer is existing member, associate with current order |
|
| 78 | + ($customer = Member::get()->filter('Email', $order->customer_email)->First()) ? |
|
| 79 | + $customer : |
|
| 80 | + $customer = Member::create(); |
|
| 81 | + |
|
| 82 | + $customer->Customer_ID = (int) $order->customer_id; |
|
| 83 | + $customer->MinifraudScore = (string) $order->minifraud_score; |
|
| 84 | + $customer->FirstName = (string) $order->customer_first_name; |
|
| 85 | + $customer->Surname = (string) $order->customer_last_name; |
|
| 86 | + $customer->Email = (string) $order->customer_email; |
|
| 87 | + $customer->Password = (string) $order->customer_password; |
|
| 88 | + $customer->Salt = (string) $order->customer_password_salt; |
|
| 89 | + $customer->PasswordEncryption = 'none'; |
|
| 90 | + |
|
| 91 | + // record member record |
|
| 92 | + $customer->write(); |
|
| 93 | 93 | |
| 94 | - // set Order MemberID |
|
| 95 | - $transaction->MemberID = $customer->ID; |
|
| 94 | + // set Order MemberID |
|
| 95 | + $transaction->MemberID = $customer->ID; |
|
| 96 | 96 | |
| 97 | - } |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | 99 | // billing address |
| 100 | 100 | ($billingAddress = OrderAddress::get()->filter('OrderID', $transaction->Order_ID)->First()) ? |
| 101 | - $billingAddress : |
|
| 102 | - $billingAddress = OrderAddress::create(); |
|
| 103 | - |
|
| 104 | - $billingAddress->Name = $customer->FirstName . ' ' . $customer->Surname; |
|
| 105 | - $billingAddress->Company = (string) $order->customer_company; |
|
| 106 | - $billingAddress->Address1 = (string) $order->customer_address1; |
|
| 107 | - $billingAddress->Address2 = (string) $order->customer_address2; |
|
| 108 | - $billingAddress->City = (string) $order->customer_city; |
|
| 109 | - $billingAddress->State = (string) $order->customer_state; |
|
| 110 | - $billingAddress->PostalCode = (string) $order->customer_postal_code; |
|
| 111 | - $billingAddress->Country = (string) $order->customer_country; |
|
| 112 | - $billingAddress->Phone = (string) $order->customer_phone; |
|
| 113 | - if($customer) $billingAddress->CustomerID = $customer->ID; |
|
| 114 | - |
|
| 115 | - // record billing address |
|
| 116 | - $billingAddress->write(); |
|
| 117 | - |
|
| 118 | - // shipping address |
|
| 119 | - ($shippingAddress = OrderAddress::get()->filter('OrderID', $transaction->Order_ID)->First()) ? |
|
| 120 | - $shippingAddress : |
|
| 121 | - $shippingAddress = OrderAddress::create(); |
|
| 122 | - |
|
| 123 | - $shippingAddress->Name = $customer->FirstName . ' ' . $customer->Surname; |
|
| 124 | - $shippingAddress->Company = (string) $order->shipping_company; |
|
| 125 | - $shippingAddress->Address1 = (string) $order->shipping_address1; |
|
| 126 | - $shippingAddress->Address2 = (string) $order->shipping_address2; |
|
| 127 | - $shippingAddress->City = (string) $order->shipping_city; |
|
| 128 | - $shippingAddress->State = (string) $order->shipping_state; |
|
| 129 | - $shippingAddress->PostalCode = (string) $order->shipping_postal_code; |
|
| 130 | - $shippingAddress->Country = (string) $order->shipping_country; |
|
| 131 | - $shippingAddress->Phone = (string) $order->shipping_phone; |
|
| 132 | - if($customer) $shippingAddress->CustomerID = $customer->ID; |
|
| 133 | - |
|
| 134 | - // record shipping address |
|
| 135 | - $shippingAddress->write(); |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - // Associate with Order |
|
| 139 | - $transaction->BillingAddressID = $billingAddress->ID; |
|
| 140 | - $transaction->ShippingAddressID = $shippingAddress->ID; |
|
| 141 | - |
|
| 142 | - |
|
| 143 | - // record transaction as order |
|
| 144 | - $transaction->write(); |
|
| 145 | - |
|
| 146 | - // remove previous $many_many Options so we don't end up with duplicates |
|
| 147 | - $transaction->Details()->removeAll(); |
|
| 148 | - |
|
| 149 | - // Associate ProductPages, Options, Quanity with Order |
|
| 150 | - foreach ($order->transaction_details->transaction_detail as $product) { |
|
| 101 | + $billingAddress : |
|
| 102 | + $billingAddress = OrderAddress::create(); |
|
| 103 | + |
|
| 104 | + $billingAddress->Name = $customer->FirstName . ' ' . $customer->Surname; |
|
| 105 | + $billingAddress->Company = (string) $order->customer_company; |
|
| 106 | + $billingAddress->Address1 = (string) $order->customer_address1; |
|
| 107 | + $billingAddress->Address2 = (string) $order->customer_address2; |
|
| 108 | + $billingAddress->City = (string) $order->customer_city; |
|
| 109 | + $billingAddress->State = (string) $order->customer_state; |
|
| 110 | + $billingAddress->PostalCode = (string) $order->customer_postal_code; |
|
| 111 | + $billingAddress->Country = (string) $order->customer_country; |
|
| 112 | + $billingAddress->Phone = (string) $order->customer_phone; |
|
| 113 | + if($customer) $billingAddress->CustomerID = $customer->ID; |
|
| 114 | + |
|
| 115 | + // record billing address |
|
| 116 | + $billingAddress->write(); |
|
| 117 | + |
|
| 118 | + // shipping address |
|
| 119 | + ($shippingAddress = OrderAddress::get()->filter('OrderID', $transaction->Order_ID)->First()) ? |
|
| 120 | + $shippingAddress : |
|
| 121 | + $shippingAddress = OrderAddress::create(); |
|
| 122 | + |
|
| 123 | + $shippingAddress->Name = $customer->FirstName . ' ' . $customer->Surname; |
|
| 124 | + $shippingAddress->Company = (string) $order->shipping_company; |
|
| 125 | + $shippingAddress->Address1 = (string) $order->shipping_address1; |
|
| 126 | + $shippingAddress->Address2 = (string) $order->shipping_address2; |
|
| 127 | + $shippingAddress->City = (string) $order->shipping_city; |
|
| 128 | + $shippingAddress->State = (string) $order->shipping_state; |
|
| 129 | + $shippingAddress->PostalCode = (string) $order->shipping_postal_code; |
|
| 130 | + $shippingAddress->Country = (string) $order->shipping_country; |
|
| 131 | + $shippingAddress->Phone = (string) $order->shipping_phone; |
|
| 132 | + if($customer) $shippingAddress->CustomerID = $customer->ID; |
|
| 133 | + |
|
| 134 | + // record shipping address |
|
| 135 | + $shippingAddress->write(); |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + // Associate with Order |
|
| 139 | + $transaction->BillingAddressID = $billingAddress->ID; |
|
| 140 | + $transaction->ShippingAddressID = $shippingAddress->ID; |
|
| 141 | + |
|
| 142 | + |
|
| 143 | + // record transaction as order |
|
| 144 | + $transaction->write(); |
|
| 145 | + |
|
| 146 | + // remove previous $many_many Options so we don't end up with duplicates |
|
| 147 | + $transaction->Details()->removeAll(); |
|
| 148 | + |
|
| 149 | + // Associate ProductPages, Options, Quanity with Order |
|
| 150 | + foreach ($order->transaction_details->transaction_detail as $product) { |
|
| 151 | 151 | |
| 152 | - $ProductOption = OrderDetail::create(); |
|
| 152 | + $ProductOption = OrderDetail::create(); |
|
| 153 | 153 | |
| 154 | - // set Quantity |
|
| 155 | - $ProductOption->Quantity = (int) $product->product_quantity; |
|
| 154 | + // set Quantity |
|
| 155 | + $ProductOption->Quantity = (int) $product->product_quantity; |
|
| 156 | 156 | |
| 157 | - // set calculated price (after option modifiers) |
|
| 158 | - $ProductOption->Price = (float) $product->product_price; |
|
| 157 | + // set calculated price (after option modifiers) |
|
| 158 | + $ProductOption->Price = (float) $product->product_price; |
|
| 159 | 159 | |
| 160 | - // Find product via product_id custom variable |
|
| 161 | - foreach ($product->transaction_detail_options->transaction_detail_option as $productID) { |
|
| 162 | - if ($productID->product_option_name == 'product_id') { |
|
| 160 | + // Find product via product_id custom variable |
|
| 161 | + foreach ($product->transaction_detail_options->transaction_detail_option as $productID) { |
|
| 162 | + if ($productID->product_option_name == 'product_id') { |
|
| 163 | 163 | |
| 164 | - $OrderProduct = ProductPage::get() |
|
| 165 | - ->filter('ID', (int) $productID->product_option_value) |
|
| 166 | - ->First(); |
|
| 164 | + $OrderProduct = ProductPage::get() |
|
| 165 | + ->filter('ID', (int) $productID->product_option_value) |
|
| 166 | + ->First(); |
|
| 167 | 167 | |
| 168 | 168 | // if product could be found, then set Option Items |
| 169 | - if ($OrderProduct) { |
|
| 169 | + if ($OrderProduct) { |
|
| 170 | 170 | |
| 171 | - // set Product |
|
| 172 | - $ProductOption->ProductID = $OrderProduct->ID; |
|
| 171 | + // set Product |
|
| 172 | + $ProductOption->ProductID = $OrderProduct->ID; |
|
| 173 | 173 | |
| 174 | - // loop through all Product Options |
|
| 175 | - foreach ($product->transaction_detail_options->transaction_detail_option as $option) { |
|
| 174 | + // loop through all Product Options |
|
| 175 | + foreach ($product->transaction_detail_options->transaction_detail_option as $option) { |
|
| 176 | 176 | |
| 177 | - $OptionItem = OptionItem::get()->filter(array( |
|
| 178 | - 'ProductID' => (string) $OrderProduct->ID, |
|
| 179 | - 'Title' => (string) $option->product_option_value |
|
| 180 | - ))->First(); |
|
| 177 | + $OptionItem = OptionItem::get()->filter(array( |
|
| 178 | + 'ProductID' => (string) $OrderProduct->ID, |
|
| 179 | + 'Title' => (string) $option->product_option_value |
|
| 180 | + ))->First(); |
|
| 181 | 181 | |
| 182 | - if ($OptionItem) { |
|
| 183 | - $ProductOption->Options()->add($OptionItem); |
|
| 182 | + if ($OptionItem) { |
|
| 183 | + $ProductOption->Options()->add($OptionItem); |
|
| 184 | 184 | |
| 185 | - // modify product price |
|
| 186 | - if($priceMod = $option->price_mod) { |
|
| 187 | - $ProductOption->Price += $priceMod; |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - } |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - // associate with this order |
|
| 195 | - $ProductOption->OrderID = $transaction->ID; |
|
| 185 | + // modify product price |
|
| 186 | + if($priceMod = $option->price_mod) { |
|
| 187 | + $ProductOption->Price += $priceMod; |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + // associate with this order |
|
| 195 | + $ProductOption->OrderID = $transaction->ID; |
|
| 196 | 196 | |
| 197 | - // extend OrderDetail parsing, allowing for recording custom fields in FoxyCart |
|
| 197 | + // extend OrderDetail parsing, allowing for recording custom fields in FoxyCart |
|
| 198 | 198 | $this->extend('handleOrderItem', $decrypted, $product, $ProductOption); |
| 199 | 199 | |
| 200 | 200 | // write |
| 201 | - $ProductOption->write(); |
|
| 201 | + $ProductOption->write(); |
|
| 202 | 202 | |
| 203 | - } |
|
| 204 | - } |
|
| 205 | - } |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // Single Sign on integration with FoxyCart |
| 209 | - public function sso() { |
|
| 210 | - |
|
| 211 | - // GET variables from FoxyCart Request |
|
| 212 | - $fcsid = $this->request->getVar('fcsid'); |
|
| 213 | - $timestampNew = strtotime('+30 days'); |
|
| 214 | - |
|
| 215 | - // get current member if logged in. If not, create a 'fake' user with Customer_ID = 0 |
|
| 216 | - // fake user will redirect to FC checkout, ask customer to log in |
|
| 217 | - // to do: consider a login/registration form here if not logged in |
|
| 218 | - if($Member = Member::currentUser()) { |
|
| 219 | - $Member = Member::currentUser(); |
|
| 220 | - } else { |
|
| 221 | - $Member = new Member(); |
|
| 222 | - $Member->Customer_ID = 0; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - $auth_token = sha1($Member->Customer_ID . '|' . $timestampNew . '|' . FoxyCart::getStoreKey()); |
|
| 226 | - |
|
| 227 | - $redirect_complete = 'https://' . FoxyCart::getFoxyCartStoreName() . '.foxycart.com/checkout?fc_auth_token=' . $auth_token . |
|
| 228 | - '&fcsid=' . $fcsid . '&fc_customer_id=' . $Member->Customer_ID . '×tamp=' . $timestampNew; |
|
| 209 | + public function sso() { |
|
| 210 | + |
|
| 211 | + // GET variables from FoxyCart Request |
|
| 212 | + $fcsid = $this->request->getVar('fcsid'); |
|
| 213 | + $timestampNew = strtotime('+30 days'); |
|
| 214 | + |
|
| 215 | + // get current member if logged in. If not, create a 'fake' user with Customer_ID = 0 |
|
| 216 | + // fake user will redirect to FC checkout, ask customer to log in |
|
| 217 | + // to do: consider a login/registration form here if not logged in |
|
| 218 | + if($Member = Member::currentUser()) { |
|
| 219 | + $Member = Member::currentUser(); |
|
| 220 | + } else { |
|
| 221 | + $Member = new Member(); |
|
| 222 | + $Member->Customer_ID = 0; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + $auth_token = sha1($Member->Customer_ID . '|' . $timestampNew . '|' . FoxyCart::getStoreKey()); |
|
| 226 | + |
|
| 227 | + $redirect_complete = 'https://' . FoxyCart::getFoxyCartStoreName() . '.foxycart.com/checkout?fc_auth_token=' . $auth_token . |
|
| 228 | + '&fcsid=' . $fcsid . '&fc_customer_id=' . $Member->Customer_ID . '×tamp=' . $timestampNew; |
|
| 229 | 229 | |
| 230 | - $this->redirect($redirect_complete); |
|
| 230 | + $this->redirect($redirect_complete); |
|
| 231 | 231 | |
| 232 | - } |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | 234 | } |
| 235 | 235 | \ No newline at end of file |
@@ -43,6 +43,9 @@ |
||
| 43 | 43 | self::setSecret(FoxyCart::getStoreKey()); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | + /** |
|
| 47 | + * @return string |
|
| 48 | + */ |
|
| 46 | 49 | public static function getSecret(){ |
| 47 | 50 | return FoxyCart::getStoreKey(); |
| 48 | 51 | } |
@@ -252,10 +252,10 @@ discard block |
||
| 252 | 252 | $input_signed = preg_replace('%([\'"])'.$prefix.preg_quote($name[2]).'\1%', '${1}'.$prefix.self::fc_hash_value($code, $name[2], $value[2], 'name', FALSE)."$1", $input); |
| 253 | 253 | } |
| 254 | 254 | self::$log[] = '<strong>INPUT:</strong> Code: <strong>'.htmlspecialchars($prefix.$code). |
| 255 | - '</strong> :: Name: <strong>'.htmlspecialchars($prefix.$name[2]). |
|
| 256 | - '</strong> :: Value: <strong>'.htmlspecialchars($value[2]). |
|
| 257 | - '</strong><br />Initial input: '.htmlspecialchars($input). |
|
| 258 | - '<br />Signed: <span style="color:#060;">'.htmlspecialchars($input_signed).'</span>'; |
|
| 255 | + '</strong> :: Name: <strong>'.htmlspecialchars($prefix.$name[2]). |
|
| 256 | + '</strong> :: Value: <strong>'.htmlspecialchars($value[2]). |
|
| 257 | + '</strong><br />Initial input: '.htmlspecialchars($input). |
|
| 258 | + '<br />Signed: <span style="color:#060;">'.htmlspecialchars($input_signed).'</span>'; |
|
| 259 | 259 | $form = str_replace($input, $input_signed, $form); |
| 260 | 260 | } |
| 261 | 261 | } |
@@ -276,10 +276,10 @@ discard block |
||
| 276 | 276 | $option[0]); |
| 277 | 277 | $form_part_signed = str_replace($option[0], $option_signed, $form_part_signed ); |
| 278 | 278 | self::$log[] = '<strong>OPTION:</strong> Code: <strong>'.htmlspecialchars($prefix.$code). |
| 279 | - '</strong> :: Name: <strong>'.htmlspecialchars($prefix.$list[2]). |
|
| 280 | - '</strong> :: Value: <strong>'.htmlspecialchars($option[2]). |
|
| 281 | - '</strong><br />Initial option: '.htmlspecialchars($option[0]). |
|
| 282 | - '<br />Signed: <span style="color:#060;">'.htmlspecialchars($option_signed).'</span>'; |
|
| 279 | + '</strong> :: Name: <strong>'.htmlspecialchars($prefix.$list[2]). |
|
| 280 | + '</strong> :: Value: <strong>'.htmlspecialchars($option[2]). |
|
| 281 | + '</strong><br />Initial option: '.htmlspecialchars($option[0]). |
|
| 282 | + '<br />Signed: <span style="color:#060;">'.htmlspecialchars($option_signed).'</span>'; |
|
| 283 | 283 | } |
| 284 | 284 | $form = str_replace($list[0], $form_part_signed, $form); |
| 285 | 285 | } |
@@ -295,10 +295,10 @@ discard block |
||
| 295 | 295 | $textarea_signed = preg_replace('%([\'"])'.preg_quote($prefix.$textarea[2]).'\1%', "$1".self::fc_hash_value($code, $textarea[2], $textarea[3], 'name', FALSE)."$1", $textarea[0]); |
| 296 | 296 | $form = str_replace($textarea[0], $textarea_signed, $form); |
| 297 | 297 | self::$log[] = '<strong>TEXTAREA:</strong> Code: <strong>'.htmlspecialchars($prefix.$code). |
| 298 | - '</strong> :: Name: <strong>'.htmlspecialchars($prefix.$textarea[2]). |
|
| 299 | - '</strong> :: Value: <strong>'.htmlspecialchars($textarea[3]). |
|
| 300 | - '</strong><br />Initial textarea: '.htmlspecialchars($textarea[0]). |
|
| 301 | - '<br />Signed: <span style="color:#060;">'.htmlspecialchars($textarea_signed).'</span>'; |
|
| 298 | + '</strong> :: Name: <strong>'.htmlspecialchars($prefix.$textarea[2]). |
|
| 299 | + '</strong> :: Value: <strong>'.htmlspecialchars($textarea[3]). |
|
| 300 | + '</strong><br />Initial textarea: '.htmlspecialchars($textarea[0]). |
|
| 301 | + '<br />Signed: <span style="color:#060;">'.htmlspecialchars($textarea_signed).'</span>'; |
|
| 302 | 302 | } |
| 303 | 303 | self::$log[] = '<strong>FORM after TEXTAREAS:</strong> <pre>'.htmlspecialchars($form).'</pre>'; |
| 304 | 304 | |
@@ -110,7 +110,7 @@ |
||
| 110 | 110 | * Products function. |
| 111 | 111 | * |
| 112 | 112 | * @access public |
| 113 | - * @return array |
|
| 113 | + * @return PaginatedList |
|
| 114 | 114 | */ |
| 115 | 115 | public function ProductList($limit = 10) { |
| 116 | 116 | |
@@ -27,9 +27,9 @@ discard block |
||
| 27 | 27 | ) |
| 28 | 28 | ); |
| 29 | 29 | |
| 30 | - private static $singular_name = 'Product Group'; |
|
| 31 | - private static $plural_name = 'Product Groups'; |
|
| 32 | - private static $description = 'Display a list of related products'; |
|
| 30 | + private static $singular_name = 'Product Group'; |
|
| 31 | + private static $plural_name = 'Product Groups'; |
|
| 32 | + private static $description = 'Display a list of related products'; |
|
| 33 | 33 | |
| 34 | 34 | private static $defaults = array( |
| 35 | 35 | |
@@ -141,9 +141,9 @@ discard block |
||
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | |
| 144 | - $list = new PaginatedList($entries, Controller::curr()->request); |
|
| 145 | - $list->setPageLength($limit); |
|
| 146 | - return $list; |
|
| 144 | + $list = new PaginatedList($entries, Controller::curr()->request); |
|
| 145 | + $list->setPageLength($limit); |
|
| 146 | + return $list; |
|
| 147 | 147 | |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @param string $pwd Key to encrypt with (can be binary of hex) |
| 33 | 33 | * @param string $data Content to be encrypted |
| 34 | - * @param bool $ispwdHex Key passed is in hexadecimal or not |
|
| 34 | + * @param integer $ispwdHex Key passed is in hexadecimal or not |
|
| 35 | 35 | * @access public |
| 36 | 36 | * @return string |
| 37 | 37 | */ |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @param string $pwd Key to decrypt with (can be binary of hex) |
| 78 | 78 | * @param string $data Content to be decrypted |
| 79 | - * @param bool $ispwdHex Key passed is in hexadecimal or not |
|
| 79 | + * @param integer $ispwdHex Key passed is in hexadecimal or not |
|
| 80 | 80 | * @access public |
| 81 | 81 | * @return string |
| 82 | 82 | */ |
@@ -10,19 +10,19 @@ |
||
| 10 | 10 | |
| 11 | 11 | static $menu_title = 'Orders'; |
| 12 | 12 | |
| 13 | - public function getEditForm($id = null, $fields = null) { |
|
| 14 | - $form = parent::getEditForm($id, $fields); |
|
| 13 | + public function getEditForm($id = null, $fields = null) { |
|
| 14 | + $form = parent::getEditForm($id, $fields); |
|
| 15 | 15 | |
| 16 | - $gridFieldName = $this->sanitiseClassName($this->modelClass); |
|
| 17 | - $gridField = $form->Fields()->fieldByName($gridFieldName); |
|
| 16 | + $gridFieldName = $this->sanitiseClassName($this->modelClass); |
|
| 17 | + $gridField = $form->Fields()->fieldByName($gridFieldName); |
|
| 18 | 18 | |
| 19 | - // GridField configuration |
|
| 20 | - $config = $gridField->getConfig(); |
|
| 19 | + // GridField configuration |
|
| 20 | + $config = $gridField->getConfig(); |
|
| 21 | 21 | |
| 22 | - // remove edit icon |
|
| 23 | - $config->removeComponentsByType('GridFieldEditButton'); |
|
| 22 | + // remove edit icon |
|
| 23 | + $config->removeComponentsByType('GridFieldEditButton'); |
|
| 24 | 24 | |
| 25 | - return $form; |
|
| 26 | - } |
|
| 25 | + return $form; |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | 28 | } |
@@ -48,69 +48,69 @@ |
||
| 48 | 48 | return sprintf('https://%s.foxycart.com/cart', self::getFoxyCartStoreName() ); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * FoxyCart API v1.1 functions |
|
| 53 | - */ |
|
| 54 | - |
|
| 55 | - // FoxyCart API Request |
|
| 56 | - private static function getAPIRequest($foxyData = array()) { |
|
| 57 | - |
|
| 58 | - $foxy_domain = FoxyCart::getFoxyCartStoreName().'.foxycart.com'; |
|
| 59 | - $foxyData["api_token"] = FoxyCart::getStoreKey(); |
|
| 60 | - |
|
| 61 | - $ch = curl_init(); |
|
| 62 | - curl_setopt($ch, CURLOPT_URL, "https://" . $foxy_domain . "/api"); |
|
| 63 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $foxyData); |
|
| 64 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 65 | - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); |
|
| 66 | - curl_setopt($ch, CURLOPT_TIMEOUT, 15); |
|
| 67 | - // If you get SSL errors, you can uncomment the following, or ask your host to add the appropriate CA bundle |
|
| 68 | - // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|
| 69 | - $response = trim(curl_exec($ch)); |
|
| 70 | - |
|
| 71 | - // The following if block will print any CURL errors you might have |
|
| 72 | - if ($response == false) { |
|
| 73 | - //trigger_error("Could not connect to FoxyCart API", E_USER_ERROR); |
|
| 74 | - SS_Log::log("Could not connect to FoxyCart API: " . $response, SS_Log::ERR); |
|
| 75 | - } |
|
| 76 | - curl_close($ch); |
|
| 77 | - |
|
| 78 | - return $response; |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - public static function getCustomer($Member = null) { |
|
| 82 | - |
|
| 83 | - // throw error if no $Member Object |
|
| 84 | - if (!isset($Member)) trigger_error('No Member set', E_USER_ERROR); |
|
| 85 | - |
|
| 86 | - // grab customer record from API |
|
| 87 | - |
|
| 88 | - $foxyData = array(); |
|
| 89 | - $foxyData["api_action"] = "customer_get"; |
|
| 90 | - if ($Member->Customer_ID) $foxyData["customer_id"] = $Member->Customer_ID; |
|
| 91 | - $foxyData["customer_email"] = $Member->Email; |
|
| 92 | - |
|
| 93 | - return self::getAPIRequest($foxyData); |
|
| 94 | - |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - public static function putCustomer($Member = null) { |
|
| 98 | - // throw error if no $Member Object |
|
| 99 | - if (!isset($Member)) ;//trigger_error('No Member set', E_USER_ERROR); |
|
| 100 | - |
|
| 101 | - // send updated customer record from API |
|
| 102 | - $foxyData = array(); |
|
| 103 | - $foxyData["api_action"] = "customer_save"; |
|
| 104 | - // customer_id will be 0 if created in SilverStripe. |
|
| 105 | - if ($Member->Customer_ID) $foxyData["customer_id"] = $Member->Customer_ID; |
|
| 106 | - $foxyData["customer_email"] = $Member->Email; |
|
| 107 | - $foxyData["customer_password_hash"] = $Member->Password; |
|
| 108 | - $foxyData["customer_password_salt"] = $Member->Salt; |
|
| 109 | - $foxyData["customer_first_name"] = $Member->FirstName; |
|
| 110 | - $foxyData["customer_last_name"] = $Member->Surname; |
|
| 111 | - |
|
| 112 | - return self::getAPIRequest($foxyData); |
|
| 113 | - } |
|
| 51 | + /** |
|
| 52 | + * FoxyCart API v1.1 functions |
|
| 53 | + */ |
|
| 54 | + |
|
| 55 | + // FoxyCart API Request |
|
| 56 | + private static function getAPIRequest($foxyData = array()) { |
|
| 57 | + |
|
| 58 | + $foxy_domain = FoxyCart::getFoxyCartStoreName().'.foxycart.com'; |
|
| 59 | + $foxyData["api_token"] = FoxyCart::getStoreKey(); |
|
| 60 | + |
|
| 61 | + $ch = curl_init(); |
|
| 62 | + curl_setopt($ch, CURLOPT_URL, "https://" . $foxy_domain . "/api"); |
|
| 63 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $foxyData); |
|
| 64 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 65 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); |
|
| 66 | + curl_setopt($ch, CURLOPT_TIMEOUT, 15); |
|
| 67 | + // If you get SSL errors, you can uncomment the following, or ask your host to add the appropriate CA bundle |
|
| 68 | + // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|
| 69 | + $response = trim(curl_exec($ch)); |
|
| 70 | + |
|
| 71 | + // The following if block will print any CURL errors you might have |
|
| 72 | + if ($response == false) { |
|
| 73 | + //trigger_error("Could not connect to FoxyCart API", E_USER_ERROR); |
|
| 74 | + SS_Log::log("Could not connect to FoxyCart API: " . $response, SS_Log::ERR); |
|
| 75 | + } |
|
| 76 | + curl_close($ch); |
|
| 77 | + |
|
| 78 | + return $response; |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + public static function getCustomer($Member = null) { |
|
| 82 | + |
|
| 83 | + // throw error if no $Member Object |
|
| 84 | + if (!isset($Member)) trigger_error('No Member set', E_USER_ERROR); |
|
| 85 | + |
|
| 86 | + // grab customer record from API |
|
| 87 | + |
|
| 88 | + $foxyData = array(); |
|
| 89 | + $foxyData["api_action"] = "customer_get"; |
|
| 90 | + if ($Member->Customer_ID) $foxyData["customer_id"] = $Member->Customer_ID; |
|
| 91 | + $foxyData["customer_email"] = $Member->Email; |
|
| 92 | + |
|
| 93 | + return self::getAPIRequest($foxyData); |
|
| 94 | + |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + public static function putCustomer($Member = null) { |
|
| 98 | + // throw error if no $Member Object |
|
| 99 | + if (!isset($Member)) ;//trigger_error('No Member set', E_USER_ERROR); |
|
| 100 | + |
|
| 101 | + // send updated customer record from API |
|
| 102 | + $foxyData = array(); |
|
| 103 | + $foxyData["api_action"] = "customer_save"; |
|
| 104 | + // customer_id will be 0 if created in SilverStripe. |
|
| 105 | + if ($Member->Customer_ID) $foxyData["customer_id"] = $Member->Customer_ID; |
|
| 106 | + $foxyData["customer_email"] = $Member->Email; |
|
| 107 | + $foxyData["customer_password_hash"] = $Member->Password; |
|
| 108 | + $foxyData["customer_password_salt"] = $Member->Salt; |
|
| 109 | + $foxyData["customer_first_name"] = $Member->FirstName; |
|
| 110 | + $foxyData["customer_last_name"] = $Member->Surname; |
|
| 111 | + |
|
| 112 | + return self::getAPIRequest($foxyData); |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | 115 | public static function getKeyPrefix(){ |
| 116 | 116 | return self::$keyPrefix; |
@@ -7,31 +7,31 @@ discard block |
||
| 7 | 7 | private static $description = ''; |
| 8 | 8 | |
| 9 | 9 | private static $db = array( |
| 10 | - 'Quantity' => 'Int', |
|
| 11 | - 'Price' => 'Currency' |
|
| 12 | - ); |
|
| 10 | + 'Quantity' => 'Int', |
|
| 11 | + 'Price' => 'Currency' |
|
| 12 | + ); |
|
| 13 | 13 | |
| 14 | 14 | private static $has_one = array( |
| 15 | - 'Product' => 'ProductPage', |
|
| 16 | - 'Order' => 'Order' |
|
| 17 | - ); |
|
| 15 | + 'Product' => 'ProductPage', |
|
| 16 | + 'Order' => 'Order' |
|
| 17 | + ); |
|
| 18 | 18 | |
| 19 | 19 | private static $many_many = array( |
| 20 | - 'Options' => 'OptionItem' |
|
| 21 | - ); |
|
| 20 | + 'Options' => 'OptionItem' |
|
| 21 | + ); |
|
| 22 | 22 | |
| 23 | 23 | private static $summary_fields = array( |
| 24 | - 'Product.Title', |
|
| 25 | - 'Quantity', |
|
| 26 | - 'Price.Nice' |
|
| 27 | - ); |
|
| 24 | + 'Product.Title', |
|
| 25 | + 'Quantity', |
|
| 26 | + 'Price.Nice' |
|
| 27 | + ); |
|
| 28 | 28 | |
| 29 | 29 | public function getCMSFields(){ |
| 30 | 30 | $fields = parent::getCMSFields(); |
| 31 | 31 | |
| 32 | - $fields->addFieldsToTab('Root.Options', array( |
|
| 33 | - GridField::create('Options', 'Product Options', $this->Options(), GridFieldConfig_RecordViewer::create()) |
|
| 34 | - )); |
|
| 32 | + $fields->addFieldsToTab('Root.Options', array( |
|
| 33 | + GridField::create('Options', 'Product Options', $this->Options(), GridFieldConfig_RecordViewer::create()) |
|
| 34 | + )); |
|
| 35 | 35 | |
| 36 | 36 | $this->extend('updateCMSFields', $fields); |
| 37 | 37 | return $fields; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function canEdit($member = null) { |
| 55 | - return false; |
|
| 55 | + return false; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | public function canDelete($member = null) { |
@@ -26,17 +26,17 @@ |
||
| 26 | 26 | |
| 27 | 27 | public function getCMSFields(){ |
| 28 | 28 | $fields = FieldList::create( |
| 29 | - TextField::create('Title') |
|
| 30 | - ->setTitle(_t('ProductImage.Title', 'Product Image Title')), |
|
| 31 | - UploadField::create('Image') |
|
| 32 | - ->setTitle(_t('ProductCategory.Image', 'Product Image')) |
|
| 33 | - ->setFolderName('Uploads/Products') |
|
| 34 | - ->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png')) |
|
| 35 | - ); |
|
| 29 | + TextField::create('Title') |
|
| 30 | + ->setTitle(_t('ProductImage.Title', 'Product Image Title')), |
|
| 31 | + UploadField::create('Image') |
|
| 32 | + ->setTitle(_t('ProductCategory.Image', 'Product Image')) |
|
| 33 | + ->setFolderName('Uploads/Products') |
|
| 34 | + ->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png')) |
|
| 35 | + ); |
|
| 36 | 36 | |
| 37 | 37 | $this->extend('updateCMSFields', $fields); |
| 38 | 38 | |
| 39 | - return $fields; |
|
| 39 | + return $fields; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function canView($member = false) { |
@@ -3,112 +3,112 @@ |
||
| 3 | 3 | class Order extends DataObject implements PermissionProvider{ |
| 4 | 4 | |
| 5 | 5 | private static $db = array( |
| 6 | - 'Order_ID' => 'Int', |
|
| 7 | - 'Store_ID' => 'Int', |
|
| 8 | - 'StoreVersion' => 'Varchar', |
|
| 9 | - 'IsTest' => 'Boolean', |
|
| 10 | - 'IsHidden' => 'Boolean', |
|
| 11 | - 'DataIsFed' => 'Boolean', |
|
| 12 | - 'TransactionDate' => 'SS_Datetime', |
|
| 13 | - 'ProcessorResponse' => 'Varchar(200)', |
|
| 14 | - 'ShiptoShippingServiceDescription' => 'Varchar(200)', |
|
| 15 | - 'ProductTotal' => 'Currency', |
|
| 16 | - 'TaxTotal' => 'Currency', |
|
| 17 | - 'ShippingTotal' => 'Currency', |
|
| 18 | - 'OrderTotal' => 'Currency', |
|
| 19 | - 'PaymentGatewayType' => 'Varchar(100)', |
|
| 20 | - 'ReceiptURL' => 'Varchar(255)', |
|
| 21 | - 'OrderStatus' => 'Varchar(255)', |
|
| 22 | - 'CustomerIP' => 'Varchar', |
|
| 23 | - 'Response' => 'Text' |
|
| 24 | - ); |
|
| 6 | + 'Order_ID' => 'Int', |
|
| 7 | + 'Store_ID' => 'Int', |
|
| 8 | + 'StoreVersion' => 'Varchar', |
|
| 9 | + 'IsTest' => 'Boolean', |
|
| 10 | + 'IsHidden' => 'Boolean', |
|
| 11 | + 'DataIsFed' => 'Boolean', |
|
| 12 | + 'TransactionDate' => 'SS_Datetime', |
|
| 13 | + 'ProcessorResponse' => 'Varchar(200)', |
|
| 14 | + 'ShiptoShippingServiceDescription' => 'Varchar(200)', |
|
| 15 | + 'ProductTotal' => 'Currency', |
|
| 16 | + 'TaxTotal' => 'Currency', |
|
| 17 | + 'ShippingTotal' => 'Currency', |
|
| 18 | + 'OrderTotal' => 'Currency', |
|
| 19 | + 'PaymentGatewayType' => 'Varchar(100)', |
|
| 20 | + 'ReceiptURL' => 'Varchar(255)', |
|
| 21 | + 'OrderStatus' => 'Varchar(255)', |
|
| 22 | + 'CustomerIP' => 'Varchar', |
|
| 23 | + 'Response' => 'Text' |
|
| 24 | + ); |
|
| 25 | 25 | |
| 26 | 26 | private static $has_one = array( |
| 27 | - 'Member' => 'Member', |
|
| 28 | - 'BillingAddress' => 'OrderAddress', |
|
| 29 | - 'ShippingAddress' => 'OrderAddress' |
|
| 30 | - ); |
|
| 27 | + 'Member' => 'Member', |
|
| 28 | + 'BillingAddress' => 'OrderAddress', |
|
| 29 | + 'ShippingAddress' => 'OrderAddress' |
|
| 30 | + ); |
|
| 31 | 31 | |
| 32 | 32 | private static $has_many = array( |
| 33 | - 'Details' => 'OrderDetail' |
|
| 34 | - ); |
|
| 35 | - |
|
| 36 | - private static $singular_name = 'Order'; |
|
| 37 | - private static $plural_name = 'Orders'; |
|
| 38 | - private static $description = 'Orders from FoxyCart Datafeed'; |
|
| 39 | - private static $default_sort = 'TransactionDate DESC'; |
|
| 40 | - |
|
| 41 | - private static $summary_fields = array( |
|
| 42 | - 'Order_ID', |
|
| 43 | - 'TransactionDate.NiceUS', |
|
| 44 | - 'Member.Name', |
|
| 45 | - 'ProductTotal.Nice', |
|
| 46 | - 'TaxTotal.Nice', |
|
| 47 | - 'ShippingTotal.Nice', |
|
| 48 | - 'OrderTotal.Nice', |
|
| 49 | - 'ReceiptLink' |
|
| 50 | - ); |
|
| 33 | + 'Details' => 'OrderDetail' |
|
| 34 | + ); |
|
| 35 | + |
|
| 36 | + private static $singular_name = 'Order'; |
|
| 37 | + private static $plural_name = 'Orders'; |
|
| 38 | + private static $description = 'Orders from FoxyCart Datafeed'; |
|
| 39 | + private static $default_sort = 'TransactionDate DESC'; |
|
| 40 | + |
|
| 41 | + private static $summary_fields = array( |
|
| 42 | + 'Order_ID', |
|
| 43 | + 'TransactionDate.NiceUS', |
|
| 44 | + 'Member.Name', |
|
| 45 | + 'ProductTotal.Nice', |
|
| 46 | + 'TaxTotal.Nice', |
|
| 47 | + 'ShippingTotal.Nice', |
|
| 48 | + 'OrderTotal.Nice', |
|
| 49 | + 'ReceiptLink' |
|
| 50 | + ); |
|
| 51 | 51 | |
| 52 | 52 | private static $searchable_fields = array( |
| 53 | - 'Order_ID', |
|
| 54 | - 'TransactionDate' => array( |
|
| 55 | - "field" => "DateField", |
|
| 56 | - "filter" => "PartialMatchFilter" |
|
| 57 | - ), |
|
| 58 | - 'Member.ID', |
|
| 59 | - 'OrderTotal', |
|
| 60 | - 'Details.ProductID' |
|
| 61 | - ); |
|
| 62 | - |
|
| 63 | - private static $casting = array( |
|
| 64 | - 'ReceiptLink' => 'HTMLVarchar' |
|
| 65 | - ); |
|
| 53 | + 'Order_ID', |
|
| 54 | + 'TransactionDate' => array( |
|
| 55 | + "field" => "DateField", |
|
| 56 | + "filter" => "PartialMatchFilter" |
|
| 57 | + ), |
|
| 58 | + 'Member.ID', |
|
| 59 | + 'OrderTotal', |
|
| 60 | + 'Details.ProductID' |
|
| 61 | + ); |
|
| 62 | + |
|
| 63 | + private static $casting = array( |
|
| 64 | + 'ReceiptLink' => 'HTMLVarchar' |
|
| 65 | + ); |
|
| 66 | 66 | |
| 67 | - private static $indexes = array( |
|
| 68 | - 'Order_ID' => true // make unique |
|
| 69 | - ); |
|
| 70 | - |
|
| 71 | - function fieldLabels($includerelations = true) { |
|
| 72 | - $labels = parent::fieldLabels(); |
|
| 73 | - |
|
| 74 | - $labels['Order_ID'] = _t('Order.Order_ID', 'Order ID#'); |
|
| 75 | - $labels['TransactionDate'] = _t('Order.TransactionDate', "Date"); |
|
| 76 | - $labels['TransactionDate.NiceUS'] = _t('Order.TransactionDate', "Date"); |
|
| 77 | - $labels['Member.Name'] = _t('Order.MemberName', 'Customer'); |
|
| 78 | - $labels['Member.ID'] = _t('Order.MemberName', 'Customer'); |
|
| 79 | - $labels['ProductTotal.Nice'] = _t('Order.ProductTotal', 'Sub Total'); |
|
| 80 | - $labels['TaxTotal.Nice'] = _t('Order.TaxTotal', 'Tax'); |
|
| 81 | - $labels['ShippingTotal.Nice'] = _t('Order.ShippingTotal', 'Shipping'); |
|
| 82 | - $labels['OrderTotal'] = _t('Order.OrderTotal', 'Total'); |
|
| 83 | - $labels['OrderTotal.Nice'] = _t('Order.OrderTotal', 'Total'); |
|
| 84 | - $labels['ReceiptLink'] = _t('Order.ReceiptLink', 'Invoice'); |
|
| 85 | - $labels['Details.ProductID'] = _t('Order.Details.ProductID', 'Product'); |
|
| 86 | - |
|
| 87 | - return $labels; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - function ReceiptLink() { |
|
| 91 | - return $this->getReceiptLink(); |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - function getReceiptLink(){ |
|
| 95 | - $obj= HTMLVarchar::create(); |
|
| 96 | - $obj->setValue('<a href="' . $this->ReceiptURL . '" target="_blank" class="cms-panel-link action external-link">view</a>'); |
|
| 97 | - return $obj; |
|
| 98 | - } |
|
| 67 | + private static $indexes = array( |
|
| 68 | + 'Order_ID' => true // make unique |
|
| 69 | + ); |
|
| 70 | + |
|
| 71 | + function fieldLabels($includerelations = true) { |
|
| 72 | + $labels = parent::fieldLabels(); |
|
| 73 | + |
|
| 74 | + $labels['Order_ID'] = _t('Order.Order_ID', 'Order ID#'); |
|
| 75 | + $labels['TransactionDate'] = _t('Order.TransactionDate', "Date"); |
|
| 76 | + $labels['TransactionDate.NiceUS'] = _t('Order.TransactionDate', "Date"); |
|
| 77 | + $labels['Member.Name'] = _t('Order.MemberName', 'Customer'); |
|
| 78 | + $labels['Member.ID'] = _t('Order.MemberName', 'Customer'); |
|
| 79 | + $labels['ProductTotal.Nice'] = _t('Order.ProductTotal', 'Sub Total'); |
|
| 80 | + $labels['TaxTotal.Nice'] = _t('Order.TaxTotal', 'Tax'); |
|
| 81 | + $labels['ShippingTotal.Nice'] = _t('Order.ShippingTotal', 'Shipping'); |
|
| 82 | + $labels['OrderTotal'] = _t('Order.OrderTotal', 'Total'); |
|
| 83 | + $labels['OrderTotal.Nice'] = _t('Order.OrderTotal', 'Total'); |
|
| 84 | + $labels['ReceiptLink'] = _t('Order.ReceiptLink', 'Invoice'); |
|
| 85 | + $labels['Details.ProductID'] = _t('Order.Details.ProductID', 'Product'); |
|
| 86 | + |
|
| 87 | + return $labels; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + function ReceiptLink() { |
|
| 91 | + return $this->getReceiptLink(); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + function getReceiptLink(){ |
|
| 95 | + $obj= HTMLVarchar::create(); |
|
| 96 | + $obj->setValue('<a href="' . $this->ReceiptURL . '" target="_blank" class="cms-panel-link action external-link">view</a>'); |
|
| 97 | + return $obj; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | 100 | public function canView($member = false) { |
| 101 | 101 | return Permission::check('Product_ORDERS'); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | public function canEdit($member = null) { |
| 105 | - //return Permission::check('Product_ORDERS'); |
|
| 106 | - return false; |
|
| 105 | + //return Permission::check('Product_ORDERS'); |
|
| 106 | + return false; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | public function canDelete($member = null) { |
| 110 | - return false; |
|
| 111 | - //return Permission::check('Product_ORDERS'); |
|
| 110 | + return false; |
|
| 111 | + //return Permission::check('Product_ORDERS'); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | public function canCreate($member = null) { |