| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | //include_once dirname(__FILE__).'/clickandpledge_common.inc'; |
|---|
| 4 | require_once dirname(__FILE__).'/clickandpledge_admin_controll.php'; |
|---|
| 5 | class Payment_ClickandPledge extends Wpjb_Payment_Abstract |
|---|
| 6 | { |
|---|
| 7 | var $responsecodes = array(); |
|---|
| 8 | public function __construct(Wpjb_Model_Payment $data = null) |
|---|
| 9 | { |
|---|
| 10 | $this->_data = $data; |
|---|
| 11 | add_action( 'wp_ajax_clickandpledge_transaction', array( __CLASS__, 'clickandpledge_transaction' ) ); |
|---|
| 12 | add_action( 'wp_ajax_nopriv_clickandpledge_transaction', array( __CLASS__, 'clickandpledge_transaction' ) ); |
|---|
| 13 | |
|---|
| 14 | $this->responsecodes = array(2054=>'Total amount is wrong',2055=>'AccountGuid is not valid',2056=>'AccountId is not valid',2057=>'Username is not valid',2058=>'Password is not valid',2059=>'Invalid recurring parameters',2060=>'Account is disabled',2101=>'Cardholder information is null',2102=>'Cardholder information is null',2103=>'Cardholder information is null',2104=>'Invalid billing country',2105=>'Credit Card number is not valid',2106=>'Cvv2 is blank',2107=>'Cvv2 length error',2108=>'Invalid currency code',2109=>'CreditCard object is null',2110=>'Invalid card type ',2111=>'Card type not currently accepted',2112=>'Card type not currently accepted',2210=>'Order item list is empty',2212=>'CurrentTotals is null',2213=>'CurrentTotals is invalid',2214=>'TicketList lenght is not equal to quantity',2215=>'NameBadge lenght is not equal to quantity',2216=>'Invalid textonticketbody',2217=>'Invalid textonticketsidebar',2218=>'Invalid NameBadgeFooter',2304=>'Shipping CountryCode is invalid',2305=>'Shipping address missed',2401=>'IP address is null',2402=>'Invalid operation',2501=>'WID is invalid',2502=>'Production transaction is not allowed. Contact support for activation.',2601=>'Invalid character in a Base-64 string',2701=>'ReferenceTransaction Information Cannot be NULL',2702=>'Invalid Refrence Transaction Information',2703=>'Expired credit card',2805=>'eCheck Account number is invalid',2807=>'Invalid payment method',2809=>'Invalid payment method',2811=>'eCheck payment type is currently not accepted',2812=>'Invalid check number',1001=>'Internal error. Retry transaction',1002=>'Error occurred on external gateway please try again',2001=>'Invalid account information',2002=>'Transaction total is not correct',2003=>'Invalid parameters',2004=>'Document is not a valid xml file',2005=>'OrderList can not be empty',3001=>'Invalid RefrenceTransactionID',3002=>'Invalid operation for this transaction',4001=>'Fraud transaction',4002=>'Duplicate transaction',5001=>'Declined (general)',5002=>'Declined (lost or stolen card)',5003=>'Declined (fraud)',5004=>'Declined (Card expired)',5005=>'Declined (Cvv2 is not valid)',5006=>'Declined (Insufficient fund)',5007=>'Declined (Invalid credit card number)'); |
|---|
| 15 | } |
|---|
| 16 | function get_user_ip() { |
|---|
| 17 | $ipaddress = ''; |
|---|
| 18 | if (isset($_SERVER['HTTP_CLIENT_IP'])) |
|---|
| 19 | $ipaddress = $_SERVER['HTTP_CLIENT_IP']; |
|---|
| 20 | else if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) |
|---|
| 21 | $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|---|
| 22 | else if(isset($_SERVER['HTTP_X_FORWARDED'])) |
|---|
| 23 | $ipaddress = $_SERVER['HTTP_X_FORWARDED']; |
|---|
| 24 | else if(isset($_SERVER['HTTP_FORWARDED_FOR'])) |
|---|
| 25 | $ipaddress = $_SERVER['HTTP_FORWARDED_FOR']; |
|---|
| 26 | else if(isset($_SERVER['HTTP_FORWARDED'])) |
|---|
| 27 | $ipaddress = $_SERVER['HTTP_FORWARDED']; |
|---|
| 28 | else |
|---|
| 29 | $ipaddress = $_SERVER['REMOTE_ADDR']; |
|---|
| 30 | $parts = explode(',', $ipaddress); |
|---|
| 31 | if(count($parts) > 1) $ipaddress = $parts[0]; |
|---|
| 32 | return $ipaddress; |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | function safeString( $str, $length=1, $start=0 ) |
|---|
| 36 | { |
|---|
| 37 | $str = preg_replace('/\x03/', '', $str); //Remove new line characters |
|---|
| 38 | return substr( htmlspecialchars( ( $str ) ), $start, $length ); |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | public function clickandpledge_transaction(){ |
|---|
| 42 | $post = $_POST; |
|---|
| 43 | global $wpdb; |
|---|
| 44 | $orderplacedcheck = $wpdb->get_row( 'SELECT * FROM '.$wpdb->prefix.'wpjb_payment WHERE id = '.$post['id'], OBJECT ); |
|---|
| 45 | if($orderplacedcheck) { |
|---|
| 46 | $post['object_id'] = $orderplacedcheck->object_id; |
|---|
| 47 | $post['object_type'] = $orderplacedcheck->object_type; |
|---|
| 48 | |
|---|
| 49 | $classObject = new Payment_ClickandPledge(); |
|---|
| 50 | $strParam = $classObject->buildXML($post); |
|---|
| 51 | $connect = array('soap_version' => SOAP_1_1, 'trace' => 1, 'exceptions' => 0); |
|---|
| 52 | $client = new SoapClient('https://paas.cloud.clickandpledge.com/paymentservice.svc?wsdl', $connect); |
|---|
| 53 | $soapParams = array('instruction'=>$strParam); |
|---|
| 54 | $response = $client->Operation($soapParams); |
|---|
| 55 | $params = array(); |
|---|
| 56 | if (($response === FALSE)) { |
|---|
| 57 | $params['error'] = 'Connection to payment gateway failed - no data returned.'; |
|---|
| 58 | $params['ResultCode'] = '99999'; |
|---|
| 59 | $params['status'] = 'Fail'; |
|---|
| 60 | } else { |
|---|
| 61 | $ResultCode=$response->OperationResult->ResultCode; |
|---|
| 62 | $transation_number=$response->OperationResult->TransactionNumber; |
|---|
| 63 | $VaultGUID=$response->OperationResult->VaultGUID; |
|---|
| 64 | |
|---|
| 65 | if($ResultCode=='0') |
|---|
| 66 | { |
|---|
| 67 | $response_message = $response->OperationResult->ResultData; |
|---|
| 68 | //Success |
|---|
| 69 | $params['TransactionNumber'] = $VaultGUID; |
|---|
| 70 | $params['trxn_result_code'] = $response_message; |
|---|
| 71 | $params['status'] = 'Success'; |
|---|
| 72 | $params['ResultCode'] = $ResultCode; |
|---|
| 73 | } |
|---|
| 74 | else |
|---|
| 75 | { |
|---|
| 76 | if( in_array( $ResultCode, array( 2051,2052,2053 ) ) ) |
|---|
| 77 | { |
|---|
| 78 | $AdditionalInfo = $response->OperationResult->AdditionalInfo; |
|---|
| 79 | } |
|---|
| 80 | else |
|---|
| 81 | { |
|---|
| 82 | if( isset( $classObject->responsecodes[$ResultCode] ) ) |
|---|
| 83 | { |
|---|
| 84 | $AdditionalInfo = $classObject->responsecodes[$ResultCode]; |
|---|
| 85 | } |
|---|
| 86 | else |
|---|
| 87 | { |
|---|
| 88 | $AdditionalInfo = 'Unknown error'; |
|---|
| 89 | } |
|---|
| 90 | } |
|---|
| 91 | $params['error'] = $AdditionalInfo; |
|---|
| 92 | $params['ResultCode'] = $ResultCode; |
|---|
| 93 | $params['status'] = 'Fail'; |
|---|
| 94 | } |
|---|
| 95 | } |
|---|
| 96 | echo json_encode($params); |
|---|
| 97 | die(); |
|---|
| 98 | } |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | public function buildXML( $post ) { |
|---|
| 102 | $params = $post; |
|---|
| 103 | |
|---|
| 104 | $dom = new DOMDocument('1.0', 'UTF-8'); |
|---|
| 105 | $root = $dom->createElement('CnPAPI', ''); |
|---|
| 106 | $root->setAttribute("xmlns","urn:APISchema.xsd"); |
|---|
| 107 | $root = $dom->appendChild($root); |
|---|
| 108 | |
|---|
| 109 | $version=$dom->createElement("Version","1.5"); |
|---|
| 110 | $version=$root->appendChild($version); |
|---|
| 111 | |
|---|
| 112 | $engine = $dom->createElement('Engine', ''); |
|---|
| 113 | $engine = $root->appendChild($engine); |
|---|
| 114 | |
|---|
| 115 | $application = $dom->createElement('Application',''); |
|---|
| 116 | $application = $engine->appendChild($application); |
|---|
| 117 | |
|---|
| 118 | $applicationid=$dom->createElement('ID','CnP_WPJobBoard_WordPress'); |
|---|
| 119 | $applicationid=$application->appendChild($applicationid); |
|---|
| 120 | |
|---|
| 121 | $applicationname=$dom->createElement('Name','CnP_WPJobBoard_WordPress'); |
|---|
| 122 | $applicationid=$application->appendChild($applicationname); |
|---|
| 123 | |
|---|
| 124 | $applicationversion=$dom->createElement('Version','1.0.0.20150604'); |
|---|
| 125 | $applicationversion=$application->appendChild($applicationversion); |
|---|
| 126 | |
|---|
| 127 | $request = $dom->createElement('Request', ''); |
|---|
| 128 | $request = $engine->appendChild($request); |
|---|
| 129 | |
|---|
| 130 | $operation=$dom->createElement('Operation',''); |
|---|
| 131 | $operation=$request->appendChild( $operation ); |
|---|
| 132 | |
|---|
| 133 | $operationtype=$dom->createElement('OperationType','Transaction'); |
|---|
| 134 | $operationtype=$operation->appendChild($operationtype); |
|---|
| 135 | |
|---|
| 136 | if($this->get_user_ip() != '') { |
|---|
| 137 | $ipaddress=$dom->createElement('IPAddress',$this->get_user_ip()); |
|---|
| 138 | $ipaddress=$operation->appendChild($ipaddress); |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | $httpreferrer=$dom->createElement('UrlReferrer',htmlentities($_SERVER['HTTP_REFERER'])); |
|---|
| 142 | $httpreferrer=$operation->appendChild($httpreferrer); |
|---|
| 143 | |
|---|
| 144 | $authentication=$dom->createElement('Authentication',''); |
|---|
| 145 | $authentication=$request->appendChild($authentication); |
|---|
| 146 | |
|---|
| 147 | $accounttype=$dom->createElement('AccountGuid',$params['clickandpledge_AccountGuid'] ); |
|---|
| 148 | $accounttype=$authentication->appendChild($accounttype); |
|---|
| 149 | |
|---|
| 150 | $accountid=$dom->createElement('AccountID',$params['clickandpledge_AccountID'] ); |
|---|
| 151 | $accountid=$authentication->appendChild($accountid); |
|---|
| 152 | |
|---|
| 153 | $order=$dom->createElement('Order',''); |
|---|
| 154 | $order=$request->appendChild($order); |
|---|
| 155 | |
|---|
| 156 | if( $params['clickandpledge_OrderMode'] == 'test' ){ |
|---|
| 157 | $orderMode = 'Test'; |
|---|
| 158 | }else{ |
|---|
| 159 | $orderMode = 'Production'; |
|---|
| 160 | } |
|---|
| 161 | $ordermode=$dom->createElement('OrderMode',$orderMode); |
|---|
| 162 | $ordermode=$order->appendChild($ordermode); |
|---|
| 163 | |
|---|
| 164 | global $wpdb; |
|---|
| 165 | $paymentdetails = $wpdb->get_row( 'SELECT * FROM '.$wpdb->prefix.'wpjb_payment WHERE id = '.$params['id'], OBJECT ); |
|---|
| 166 | //Object Type:1-wpjb_job, 2 - wpjb_resume, 3 - wpjb_membership |
|---|
| 167 | $orderdetails = array(); |
|---|
| 168 | $orderdetails['BillingEmail'] = $paymentdetails->email; |
|---|
| 169 | $orderdetails['CustomFields'] = array(); |
|---|
| 170 | $order_custom_fields = $wpdb->get_results( 'SELECT * FROM '.$wpdb->prefix.'wpjb_meta meta INNER JOIN '.$wpdb->prefix.'wpjb_meta_value meta_value ON meta.id=meta_value.meta_id WHERE meta.meta_type=3 AND meta_value.object_id = '.$params['object_id'].' ORDER BY meta_value.meta_id ASC', OBJECT ); |
|---|
| 171 | if(count($order_custom_fields) > 0) { |
|---|
| 172 | $oldname = $strval = ''; |
|---|
| 173 | $fieldindex = 0; |
|---|
| 174 | foreach($order_custom_fields as $single_row) { |
|---|
| 175 | $fieldindex++; |
|---|
| 176 | if($oldname == '') $oldname = $single_row->name; |
|---|
| 177 | if($oldname != $single_row->name) { |
|---|
| 178 | $orderdetails['CustomFields'][$oldname] = substr($strval,0,-1); |
|---|
| 179 | $strval = ''; |
|---|
| 180 | } |
|---|
| 181 | if(count($order_custom_fields) == $fieldindex) { |
|---|
| 182 | $orderdetails['CustomFields'][$single_row->name] = $single_row->value; |
|---|
| 183 | } |
|---|
| 184 | $strval .= $single_row->value.','; |
|---|
| 185 | $oldname = $single_row->name; |
|---|
| 186 | } |
|---|
| 187 | } |
|---|
| 188 | if(isset($post['clickandpledge_listing_id']) && $post['clickandpledge_listing_id'] != '') { |
|---|
| 189 | $parts = explode('_', $post['clickandpledge_listing_id']); |
|---|
| 190 | if(count($parts) == 3) { |
|---|
| 191 | $listid = $parts[2]; |
|---|
| 192 | if($listid != '') { |
|---|
| 193 | $listrow = $wpdb->get_row( 'SELECT * FROM '.$wpdb->prefix.'wpjb_pricing WHERE id = '.$listid, OBJECT ); |
|---|
| 194 | if($listrow != '') { |
|---|
| 195 | $orderdetails['CustomFields']['Listing Type'] = $listrow->title; |
|---|
| 196 | } |
|---|
| 197 | } |
|---|
| 198 | } |
|---|
| 199 | } |
|---|
| 200 | if($params['object_type'] == 1) { |
|---|
| 201 | $orderplaced = $wpdb->get_row( 'SELECT * FROM '.$wpdb->prefix.'wpjb_job WHERE id = '.$params['object_id'], OBJECT ); |
|---|
| 202 | $orderdetails['ItemName'] = 'Job: '.$orderplaced->job_title; |
|---|
| 203 | if($orderplaced->job_description != '') |
|---|
| 204 | $orderdetails['CustomFields']['Description'] = $orderplaced->job_description; |
|---|
| 205 | if($orderplaced->job_country != '') { |
|---|
| 206 | $countries = Wpjb_List_Country::getAll(); |
|---|
| 207 | if(count($countries) > 0) { |
|---|
| 208 | foreach($countries as $country) { |
|---|
| 209 | if($country['code'] == $orderplaced->job_country) |
|---|
| 210 | $orderdetails['CustomFields']['Job Country'] = $country['name']; |
|---|
| 211 | } |
|---|
| 212 | } |
|---|
| 213 | |
|---|
| 214 | } |
|---|
| 215 | if($orderplaced->job_state != '') |
|---|
| 216 | $orderdetails['CustomFields']['Job State'] = $orderplaced->job_state; |
|---|
| 217 | if($orderplaced->job_zip_code != '') |
|---|
| 218 | $orderdetails['CustomFields']['Job Zip-Code'] = $orderplaced->job_zip_code; |
|---|
| 219 | if($orderplaced->job_city != '') |
|---|
| 220 | $orderdetails['CustomFields']['Job City'] = $orderplaced->job_city; |
|---|
| 221 | if($orderplaced->company_name != '') |
|---|
| 222 | $orderdetails['CustomFields']['Company Name'] = $orderplaced->company_name; |
|---|
| 223 | if($orderplaced->company_email != '') |
|---|
| 224 | $orderdetails['CustomFields']['Contact Email'] = $orderplaced->company_email; |
|---|
| 225 | if($orderplaced->company_url != '') |
|---|
| 226 | $orderdetails['CustomFields']['Website'] = $orderplaced->company_url; |
|---|
| 227 | |
|---|
| 228 | $job = new Wpjb_Model_Job($params['object_id']); |
|---|
| 229 | if(isset($job->getTag()->type) && is_array($job->getTag()->type)) { |
|---|
| 230 | foreach($job->getTag()->type as $type) { |
|---|
| 231 | $orderdetails['CustomFields']['Job Type'] = $type->title; |
|---|
| 232 | } |
|---|
| 233 | } |
|---|
| 234 | if(isset($job->tag->category) && is_array($job->tag->category)) { |
|---|
| 235 | foreach($job->tag->category as $cat) { |
|---|
| 236 | $orderdetails['CustomFields']['Category'] = $cat->title; |
|---|
| 237 | } |
|---|
| 238 | } |
|---|
| 239 | |
|---|
| 240 | } else if($params['object_type'] == 2) { //Resume |
|---|
| 241 | $orderplaced = $wpdb->get_row( 'SELECT * FROM '.$wpdb->prefix.'wpjb_resume r INNER JOIN '.$wpdb->prefix.'posts p ON r.post_id = p.id WHERE r.id = '.$params['object_id'], OBJECT ); |
|---|
| 242 | if($orderplaced) { |
|---|
| 243 | if($orderplaced->post_title != '') { |
|---|
| 244 | $orderdetails['ItemName'] = 'Resume: '.$orderplaced->post_title; |
|---|
| 245 | }else { |
|---|
| 246 | $orderdetails['ItemName'] = 'Single Resume Access'; |
|---|
| 247 | } |
|---|
| 248 | } |
|---|
| 249 | else { |
|---|
| 250 | $orderdetails['ItemName'] = 'Single Resume Access'; |
|---|
| 251 | } |
|---|
| 252 | } else if($params['object_type'] == 3) { //Membership |
|---|
| 253 | $orderplaced = $wpdb->get_row( 'SELECT * FROM '.$wpdb->prefix.'wpjb_membership WHERE id = '.$params['object_id'], OBJECT ); |
|---|
| 254 | if($orderplaced->package_id != '') { |
|---|
| 255 | $package = $wpdb->get_row( 'SELECT * FROM '.$wpdb->prefix.'wpjb_pricing WHERE id = '.$orderplaced->package_id, OBJECT ); |
|---|
| 256 | $orderdetails['ItemName'] = 'Membership: '.$package->title; |
|---|
| 257 | } else { |
|---|
| 258 | $orderdetails['ItemName'] = 'Employer Membership Package'; |
|---|
| 259 | } |
|---|
| 260 | } |
|---|
| 261 | $UnitPriceCalculate = $TotalDiscountCalculate = 0; |
|---|
| 262 | |
|---|
| 263 | $cardholder=$dom->createElement('CardHolder',''); |
|---|
| 264 | $cardholder=$order->appendChild($cardholder); |
|---|
| 265 | |
|---|
| 266 | $billinginfo=$dom->createElement('BillingInformation',''); |
|---|
| 267 | $billinginfo=$cardholder->appendChild($billinginfo); |
|---|
| 268 | |
|---|
| 269 | if(isset($post['clickandpledge_selectedPaymentMethod']) && $post['clickandpledge_selectedPaymentMethod'] == 'CreditCard') { |
|---|
| 270 | $billfirst_name=$dom->createElement('BillingFirstName',$this->safeString($params['clickandpledge_FirstName_CreditCard'],50)); |
|---|
| 271 | $billfirst_name=$billinginfo->appendChild($billfirst_name); |
|---|
| 272 | $billlast_name=$dom->createElement('BillingLastName',$this->safeString($params['clickandpledge_LastName_CreditCard'],50)); |
|---|
| 273 | $billlast_name=$billinginfo->appendChild($billlast_name); |
|---|
| 274 | } else if(isset($post['clickandpledge_selectedPaymentMethod']) && $post['clickandpledge_selectedPaymentMethod'] == 'eCheck') { |
|---|
| 275 | $billfirst_name=$dom->createElement('BillingFirstName',$this->safeString($params['clickandpledge_FirstName_eCheck'],50)); |
|---|
| 276 | $billfirst_name=$billinginfo->appendChild($billfirst_name); |
|---|
| 277 | $billlast_name=$dom->createElement('BillingLastName',$this->safeString($params['clickandpledge_LastName_eCheck'],50)); |
|---|
| 278 | $billlast_name=$billinginfo->appendChild($billlast_name); |
|---|
| 279 | } else if(isset($post['clickandpledge_selectedPaymentMethod']) && $post['clickandpledge_selectedPaymentMethod'] == 'Invoice') { |
|---|
| 280 | $billfirst_name=$dom->createElement('BillingFirstName',$this->safeString($params['clickandpledge_FirstName_Invoice'],50)); |
|---|
| 281 | $billfirst_name=$billinginfo->appendChild($billfirst_name); |
|---|
| 282 | $billlast_name=$dom->createElement('BillingLastName',$this->safeString($params['clickandpledge_LastName_Invoice'],50)); |
|---|
| 283 | $billlast_name=$billinginfo->appendChild($billlast_name); |
|---|
| 284 | } else if(isset($post['clickandpledge_selectedPaymentMethod']) && $post['clickandpledge_selectedPaymentMethod'] == 'PurchaseOrder') { |
|---|
| 285 | $billfirst_name=$dom->createElement('BillingFirstName',$this->safeString($params['clickandpledge_FirstName_PO'],50)); |
|---|
| 286 | $billfirst_name=$billinginfo->appendChild($billfirst_name); |
|---|
| 287 | $billlast_name=$dom->createElement('BillingLastName',$this->safeString($params['clickandpledge_LastName_PO'],50)); |
|---|
| 288 | $billlast_name=$billinginfo->appendChild($billlast_name); |
|---|
| 289 | } |
|---|
| 290 | |
|---|
| 291 | if (isset($orderdetails['BillingEmail']) && $orderdetails['BillingEmail'] != '') { |
|---|
| 292 | $bill_email=$dom->createElement('BillingEmail',$orderdetails['BillingEmail']); |
|---|
| 293 | $bill_email=$billinginfo->appendChild($bill_email); |
|---|
| 294 | } |
|---|
| 295 | //echo 'SELECT * FROM '.$wpdb->prefix.'wpjb_job WHERE post_id = '.$params['id']; |
|---|
| 296 | //echo '<pre>'; |
|---|
| 297 | //print_r($orderplaced); |
|---|
| 298 | //die('fffffffffff'); |
|---|
| 299 | $billingaddress=$dom->createElement('BillingAddress',''); |
|---|
| 300 | $billingaddress=$cardholder->appendChild($billingaddress); |
|---|
| 301 | |
|---|
| 302 | if(isset($orderdetails['CustomFields']) && count($orderdetails['CustomFields']) > 0) { |
|---|
| 303 | $customfieldlist = $dom->createElement('CustomFieldList',''); |
|---|
| 304 | $customfieldlist = $cardholder->appendChild($customfieldlist); |
|---|
| 305 | |
|---|
| 306 | foreach($orderdetails['CustomFields'] as $key => $val) { |
|---|
| 307 | $customfield = $dom->createElement('CustomField',''); |
|---|
| 308 | $customfield = $customfieldlist->appendChild($customfield); |
|---|
| 309 | |
|---|
| 310 | $fieldname = $dom->createElement('FieldName',$key); |
|---|
| 311 | $fieldname = $customfield->appendChild($fieldname); |
|---|
| 312 | |
|---|
| 313 | $fieldvalue = $dom->createElement('FieldValue',$this->safeString($val, 500)); |
|---|
| 314 | $fieldvalue = $customfield->appendChild($fieldvalue); |
|---|
| 315 | } |
|---|
| 316 | } |
|---|
| 317 | |
|---|
| 318 | $paymentmethod=$dom->createElement('PaymentMethod',''); |
|---|
| 319 | $paymentmethod=$cardholder->appendChild($paymentmethod); |
|---|
| 320 | |
|---|
| 321 | if(isset($post['clickandpledge_selectedPaymentMethod']) && $post['clickandpledge_selectedPaymentMethod'] == 'CreditCard') { |
|---|
| 322 | $payment_type=$dom->createElement('PaymentType','CreditCard'); |
|---|
| 323 | $payment_type=$paymentmethod->appendChild($payment_type); |
|---|
| 324 | |
|---|
| 325 | $creditcard=$dom->createElement('CreditCard',''); |
|---|
| 326 | $creditcard=$paymentmethod->appendChild($creditcard); |
|---|
| 327 | $credit_card_name = ''; |
|---|
| 328 | if (isset($params['clickandpledge_nameOnCard']) && $params['clickandpledge_nameOnCard'] != '') { |
|---|
| 329 | $credit_card_name .= ' '.$params['clickandpledge_nameOnCard']; |
|---|
| 330 | } |
|---|
| 331 | |
|---|
| 332 | $credit_name=$dom->createElement('NameOnCard',$this->safeString( $credit_card_name, 50)); |
|---|
| 333 | $credit_name=$creditcard->appendChild($credit_name); |
|---|
| 334 | |
|---|
| 335 | $credit_number=$dom->createElement('CardNumber',$this->safeString( str_replace(' ', '', $params['clickandpledge_cardNumber']), 17)); |
|---|
| 336 | $credit_number=$creditcard->appendChild($credit_number); |
|---|
| 337 | |
|---|
| 338 | $credit_cvv=$dom->createElement('Cvv2',$params['clickandpledge_cvc']); |
|---|
| 339 | $credit_cvv=$creditcard->appendChild($credit_cvv); |
|---|
| 340 | |
|---|
| 341 | $credit_expdate=$dom->createElement('ExpirationDate',$params['clickandpledge_cardExpMonth'] . "/" . substr($params['clickandpledge_cardExpYear'],2,2)); |
|---|
| 342 | $credit_expdate=$creditcard->appendChild($credit_expdate); |
|---|
| 343 | } |
|---|
| 344 | elseif(isset($post['clickandpledge_selectedPaymentMethod']) && $post['clickandpledge_selectedPaymentMethod'] == 'eCheck') { |
|---|
| 345 | $payment_type=$dom->createElement('PaymentType','Check'); |
|---|
| 346 | $payment_type=$paymentmethod->appendChild($payment_type); |
|---|
| 347 | |
|---|
| 348 | $echeck=$dom->createElement('Check',''); |
|---|
| 349 | $echeck=$paymentmethod->appendChild($echeck); |
|---|
| 350 | if(!empty($post['clickandpledge_echeck_AccountNumber'])) { |
|---|
| 351 | $ecAccount=$dom->createElement('AccountNumber',$this->safeString( $post['clickandpledge_echeck_AccountNumber'], 17)); |
|---|
| 352 | $ecAccount=$echeck->appendChild($ecAccount); |
|---|
| 353 | } |
|---|
| 354 | if(!empty($post['clickandpledge_echeck_AccountType'])) { |
|---|
| 355 | $ecAccount_type=$dom->createElement('AccountType',$post['clickandpledge_echeck_AccountType']); |
|---|
| 356 | $ecAccount_type=$echeck->appendChild($ecAccount_type); |
|---|
| 357 | } |
|---|
| 358 | if(!empty($post['clickandpledge_echeck_RoutingNumber'])) { |
|---|
| 359 | $ecRouting=$dom->createElement('RoutingNumber',$this->safeString( $post['clickandpledge_echeck_RoutingNumber'], 9)); |
|---|
| 360 | $ecRouting=$echeck->appendChild($ecRouting); |
|---|
| 361 | } |
|---|
| 362 | if(!empty($post['clickandpledge_echeck_CheckNumber'])) { |
|---|
| 363 | $ecCheck=$dom->createElement('CheckNumber',$this->safeString( $post['clickandpledge_echeck_CheckNumber'], 10)); |
|---|
| 364 | $ecCheck=$echeck->appendChild($ecCheck); |
|---|
| 365 | } |
|---|
| 366 | if(!empty($post['clickandpledge_echeck_CheckType'])) { |
|---|
| 367 | $ecChecktype=$dom->createElement('CheckType',$post['clickandpledge_echeck_CheckType']); |
|---|
| 368 | $ecChecktype=$echeck->appendChild($ecChecktype); |
|---|
| 369 | } |
|---|
| 370 | if(!empty($post['clickandpledge_echeck_NameOnAccount'])) { |
|---|
| 371 | $ecName=$dom->createElement('NameOnAccount',$this->safeString( $post['clickandpledge_echeck_NameOnAccount'], 100)); |
|---|
| 372 | $ecName=$echeck->appendChild($ecName); |
|---|
| 373 | } |
|---|
| 374 | if(!empty($post['clickandpledge_echeck_IdType'])) { |
|---|
| 375 | $ecIdtype=$dom->createElement('IdType',$post['clickandpledge_echeck_IdType']); |
|---|
| 376 | $ecIdtype=$echeck->appendChild($ecIdtype); |
|---|
| 377 | } |
|---|
| 378 | if(!empty($post['clickandpledge_echeck_IdNumber'])) { |
|---|
| 379 | $IdNumber=$dom->createElement('IdNumber',$this->safeString( $post['clickandpledge_echeck_IdNumber'], 30)); |
|---|
| 380 | $IdNumber=$creditcard->appendChild($IdNumber); |
|---|
| 381 | } |
|---|
| 382 | if(!empty($post['clickandpledge_echeck_IdStateCode'])) { |
|---|
| 383 | $IdStateCode=$dom->createElement('IdStateCode', $post['clickandpledge_echeck_IdStateCode']); |
|---|
| 384 | $IdStateCode=$creditcard->appendChild($IdStateCode); |
|---|
| 385 | } |
|---|
| 386 | } |
|---|
| 387 | elseif(isset($post['clickandpledge_selectedPaymentMethod']) && $post['clickandpledge_selectedPaymentMethod'] == 'Invoice') { |
|---|
| 388 | $payment_type=$dom->createElement('PaymentType','Invoice'); |
|---|
| 389 | $payment_type=$paymentmethod->appendChild($payment_type); |
|---|
| 390 | $invoice=$dom->createElement('Invoice',''); |
|---|
| 391 | $invoice=$paymentmethod->appendChild($invoice); |
|---|
| 392 | $CheckNumber=$dom->createElement('InvoiceCheckNumber',$post['InvoiceCheckNumber']); |
|---|
| 393 | $CheckNumber=$invoice->appendChild($CheckNumber); |
|---|
| 394 | } |
|---|
| 395 | elseif(isset($post['clickandpledge_selectedPaymentMethod']) && $post['clickandpledge_selectedPaymentMethod'] == 'PurchaseOrder') { |
|---|
| 396 | $payment_type=$dom->createElement('PaymentType','PurchaseOrder'); |
|---|
| 397 | $payment_type=$paymentmethod->appendChild($payment_type); |
|---|
| 398 | $PurchaseOrder=$dom->createElement('PurchaseOrder',''); |
|---|
| 399 | $PurchaseOrder=$paymentmethod->appendChild($PurchaseOrder); |
|---|
| 400 | $CheckNumber=$dom->createElement('PurchaseOrderNumber',$post['PurchaseOrderNumber']); |
|---|
| 401 | $CheckNumber=$PurchaseOrder->appendChild($CheckNumber); |
|---|
| 402 | } else { |
|---|
| 403 | $payment_type=$dom->createElement('PaymentType','CreditCard'); |
|---|
| 404 | $payment_type=$paymentmethod->appendChild($payment_type); |
|---|
| 405 | |
|---|
| 406 | $creditcard=$dom->createElement('CreditCard',''); |
|---|
| 407 | $creditcard=$paymentmethod->appendChild($creditcard); |
|---|
| 408 | |
|---|
| 409 | $credit_card_name = ''; |
|---|
| 410 | if (isset($params['clickandpledge_nameOnCard_First']) && $params['clickandpledge_nameOnCard_First'] != '') { |
|---|
| 411 | $credit_card_name .= $params['clickandpledge_nameOnCard_First']; |
|---|
| 412 | } |
|---|
| 413 | if (isset($params['clickandpledge_nameOnCard_Last']) && $params['clickandpledge_nameOnCard_Last'] != '') { |
|---|
| 414 | $credit_card_name .= ' '.$params['clickandpledge_nameOnCard_Last']; |
|---|
| 415 | } |
|---|
| 416 | |
|---|
| 417 | $credit_name=$dom->createElement('NameOnCard',$this->safeString( $credit_card_name, 50)); |
|---|
| 418 | $credit_name=$creditcard->appendChild($credit_name); |
|---|
| 419 | |
|---|
| 420 | $credit_number=$dom->createElement('CardNumber',$this->safeString( str_replace(' ', '', $params['clickandpledge_cardNumber']), 17)); |
|---|
| 421 | $credit_number=$creditcard->appendChild($credit_number); |
|---|
| 422 | |
|---|
| 423 | $credit_cvv=$dom->createElement('Cvv2',$params['clickandpledge_cvc']); |
|---|
| 424 | $credit_cvv=$creditcard->appendChild($credit_cvv); |
|---|
| 425 | |
|---|
| 426 | $credit_expdate=$dom->createElement('ExpirationDate',$params['clickandpledge_cardExpMonth'] . "/" . substr($params['clickandpledge_cardExpYear'],2,2)); |
|---|
| 427 | $credit_expdate=$creditcard->appendChild($credit_expdate); |
|---|
| 428 | } |
|---|
| 429 | |
|---|
| 430 | $orderitemlist=$dom->createElement('OrderItemList',''); |
|---|
| 431 | $orderitemlist=$order->appendChild($orderitemlist); |
|---|
| 432 | |
|---|
| 433 | $orderitem=$dom->createElement('OrderItem',''); |
|---|
| 434 | $orderitem=$orderitemlist->appendChild($orderitem); |
|---|
| 435 | |
|---|
| 436 | $itemid=$dom->createElement('ItemID',1); |
|---|
| 437 | $itemid=$orderitem->appendChild($itemid); |
|---|
| 438 | |
|---|
| 439 | $itemname=$dom->createElement('ItemName',$this->safeString(trim($orderdetails['ItemName']), 100)); |
|---|
| 440 | $itemname=$orderitem->appendChild($itemname); |
|---|
| 441 | |
|---|
| 442 | $quntity=$dom->createElement('Quantity',1); |
|---|
| 443 | $quntity=$orderitem->appendChild($quntity); |
|---|
| 444 | $line_subtotal = $params['clickandpledge_Amount']; |
|---|
| 445 | if( isset($params['clickandpledge_isRecurring']) && $params['clickandpledge_isRecurring'] == 'true' ) { |
|---|
| 446 | if($params['clickandpledge_RecurringMethod'] == 'Installment') { |
|---|
| 447 | if(isset($params['clickandpledge_indefinite']) && $params['clickandpledge_indefinite'] == 'true') { |
|---|
| 448 | $UnitPriceDecimal = ($this->number_format(($line_subtotal/999),2,'.','')*100); |
|---|
| 449 | $UnitPriceCalculate += ($this->number_format(($line_subtotal/999),2,'.','')*1); |
|---|
| 450 | } else { |
|---|
| 451 | $UnitPriceDecimal = ($this->number_format(($line_subtotal/$params['clickandpledge_Installment']),2,'.','')*100); |
|---|
| 452 | $UnitPriceCalculate += ($this->number_format(($line_subtotal/$params['clickandpledge_Installment']),2,'.','')*1); |
|---|
| 453 | } |
|---|
| 454 | $unitprice=$dom->createElement('UnitPrice', $UnitPriceDecimal); |
|---|
| 455 | $unitprice=$orderitem->appendChild($unitprice); |
|---|
| 456 | } else { |
|---|
| 457 | $unitprice=$dom->createElement('UnitPrice',($line_subtotal*100)); |
|---|
| 458 | $unitprice=$orderitem->appendChild($unitprice); |
|---|
| 459 | //New Fix |
|---|
| 460 | $UnitPriceCalculate += ($line_subtotal*1); |
|---|
| 461 | } |
|---|
| 462 | } else { |
|---|
| 463 | $unitprice=$dom->createElement('UnitPrice',($line_subtotal*100)); |
|---|
| 464 | $unitprice=$orderitem->appendChild($unitprice); |
|---|
| 465 | $UnitPriceCalculate += ($line_subtotal*1); |
|---|
| 466 | } |
|---|
| 467 | |
|---|
| 468 | //Discount |
|---|
| 469 | if($params['clickandpledge_Discount'] > 0) { |
|---|
| 470 | $order_discount = $params['clickandpledge_Discount']; |
|---|
| 471 | if( isset($params['clickandpledge_isRecurring']) && $params['clickandpledge_isRecurring'] == 'true' ) { |
|---|
| 472 | if($params['clickandpledge_RecurringMethod'] == 'Installment') { |
|---|
| 473 | $TotalDiscount = ($order_discount)/$params['clickandpledge_Installment']; |
|---|
| 474 | $TotalDiscount = $this->number_format($TotalDiscount, 2, '.', '')*100; |
|---|
| 475 | } else { |
|---|
| 476 | $TotalDiscount = $this->number_format($order_discount, 2, '.', '')*100; |
|---|
| 477 | } |
|---|
| 478 | } else { |
|---|
| 479 | $TotalDiscount = $this->number_format($order_discount, 2, '.', '')*100; |
|---|
| 480 | } |
|---|
| 481 | if($TotalDiscount > 0) { |
|---|
| 482 | $unit_disc=$dom->createElement('UnitDiscount', $TotalDiscount); |
|---|
| 483 | $unit_disc=$orderitem->appendChild($unit_disc); |
|---|
| 484 | $TotalDiscountCalculate = $TotalDiscount; |
|---|
| 485 | } |
|---|
| 486 | } |
|---|
| 487 | |
|---|
| 488 | $receipt=$dom->createElement('Receipt',''); |
|---|
| 489 | $receipt=$order->appendChild($receipt); |
|---|
| 490 | |
|---|
| 491 | $recipt_lang=$dom->createElement('Language','ENG'); |
|---|
| 492 | $recipt_lang=$receipt->appendChild($recipt_lang); |
|---|
| 493 | |
|---|
| 494 | if( isset($params['clickandpledge_OrganizationInformation']) && $params['clickandpledge_OrganizationInformation'] != '') |
|---|
| 495 | { |
|---|
| 496 | $recipt_org=$dom->createElement('OrganizationInformation',$this->safeString($params['clickandpledge_OrganizationInformation'], 1500)); |
|---|
| 497 | $recipt_org=$receipt->appendChild($recipt_org); |
|---|
| 498 | } |
|---|
| 499 | |
|---|
| 500 | if( isset($params['clickandpledge_TermsCondition']) && $params['clickandpledge_TermsCondition'] != '') |
|---|
| 501 | { |
|---|
| 502 | $recipt_terms=$dom->createElement('TermsCondition',$this->safeString($params['clickandpledge_TermsCondition'], 1500)); |
|---|
| 503 | $recipt_terms=$receipt->appendChild($recipt_terms); |
|---|
| 504 | } |
|---|
| 505 | |
|---|
| 506 | if( isset($params['clickandpledge_email_customer']) && $params['clickandpledge_email_customer'] == 'yes' ) { //Sending the email based on admin settings |
|---|
| 507 | $recipt_email=$dom->createElement('EmailNotificationList',''); |
|---|
| 508 | $recipt_email=$receipt->appendChild($recipt_email); |
|---|
| 509 | |
|---|
| 510 | $email_notification = ''; |
|---|
| 511 | if (isset($params['billing_email']) && $params['billing_email'] != '') { |
|---|
| 512 | $email_notification = $params['billing_email']; |
|---|
| 513 | } |
|---|
| 514 | |
|---|
| 515 | $email_note=$dom->createElement('NotificationEmail',$email_notification); |
|---|
| 516 | $email_note=$recipt_email->appendChild($email_note); |
|---|
| 517 | } |
|---|
| 518 | $transation=$dom->createElement('Transaction',''); |
|---|
| 519 | $transation=$order->appendChild($transation); |
|---|
| 520 | |
|---|
| 521 | $trans_type=$dom->createElement('TransactionType','Payment'); |
|---|
| 522 | $trans_type=$transation->appendChild($trans_type); |
|---|
| 523 | |
|---|
| 524 | $trans_desc=$dom->createElement('DynamicDescriptor','DynamicDescriptor'); |
|---|
| 525 | $trans_desc=$transation->appendChild($trans_desc); |
|---|
| 526 | |
|---|
| 527 | |
|---|
| 528 | if( isset($params['clickandpledge_isRecurring']) && $params['clickandpledge_isRecurring'] == 'true' ) |
|---|
| 529 | { |
|---|
| 530 | $trans_recurr=$dom->createElement('Recurring',''); |
|---|
| 531 | $trans_recurr=$transation->appendChild($trans_recurr); |
|---|
| 532 | if (isset($params['clickandpledge_indefinite']) && $params['clickandpledge_indefinite'] == 'true' ) |
|---|
| 533 | { |
|---|
| 534 | $total_installment=$dom->createElement('Installment',999); |
|---|
| 535 | $total_installment=$trans_recurr->appendChild($total_installment); |
|---|
| 536 | } |
|---|
| 537 | else |
|---|
| 538 | { |
|---|
| 539 | if($params['clickandpledge_Installment'] != '') { |
|---|
| 540 | $total_installment=$dom->createElement('Installment',$params['clickandpledge_Installment']); |
|---|
| 541 | $total_installment=$trans_recurr->appendChild($total_installment); |
|---|
| 542 | } else { |
|---|
| 543 | $total_installment=$dom->createElement('Installment',1); |
|---|
| 544 | $total_installment=$trans_recurr->appendChild($total_installment); |
|---|
| 545 | } |
|---|
| 546 | } |
|---|
| 547 | $total_periodicity=$dom->createElement('Periodicity',$params['clickandpledge_Periodicity']); |
|---|
| 548 | $total_periodicity=$trans_recurr->appendChild($total_periodicity); |
|---|
| 549 | |
|---|
| 550 | if( isset($params['clickandpledge_RecurringMethod']) ) { |
|---|
| 551 | $RecurringMethod=$dom->createElement('RecurringMethod',$params['clickandpledge_RecurringMethod']); |
|---|
| 552 | $RecurringMethod=$trans_recurr->appendChild($RecurringMethod); |
|---|
| 553 | } else { |
|---|
| 554 | $RecurringMethod=$dom->createElement('RecurringMethod','Subscription'); |
|---|
| 555 | $RecurringMethod=$trans_recurr->appendChild($RecurringMethod); |
|---|
| 556 | } |
|---|
| 557 | } |
|---|
| 558 | |
|---|
| 559 | $trans_totals=$dom->createElement('CurrentTotals',''); |
|---|
| 560 | $trans_totals=$transation->appendChild($trans_totals); |
|---|
| 561 | if($TotalDiscountCalculate > 0) { |
|---|
| 562 | $total_discount=$dom->createElement('TotalDiscount',$TotalDiscountCalculate); |
|---|
| 563 | $total_discount=$trans_totals->appendChild($total_discount); |
|---|
| 564 | } |
|---|
| 565 | |
|---|
| 566 | if( isset($params['clickandpledge_isRecurring']) && $params['clickandpledge_isRecurring'] == 'true' ) { |
|---|
| 567 | if($params['clickandpledge_RecurringMethod'] == 'Installment') { |
|---|
| 568 | $Total = $this->number_format($UnitPriceCalculate, 2, '.', '')*100 - $TotalDiscountCalculate; |
|---|
| 569 | $total_amount=$dom->createElement('Total', $Total); |
|---|
| 570 | $total_amount=$trans_totals->appendChild($total_amount); |
|---|
| 571 | } else { |
|---|
| 572 | $Total = $this->number_format($UnitPriceCalculate, 2, '.', '')*100 - $TotalDiscountCalculate;; |
|---|
| 573 | $total_amount=$dom->createElement('Total',$Total); |
|---|
| 574 | $total_amount=$trans_totals->appendChild($total_amount); |
|---|
| 575 | } |
|---|
| 576 | } else { |
|---|
| 577 | $Total = $this->number_format($UnitPriceCalculate, 2, '.', '')*100 - $TotalDiscountCalculate;; |
|---|
| 578 | $total_amount=$dom->createElement('Total',$Total); |
|---|
| 579 | $total_amount=$trans_totals->appendChild($total_amount); |
|---|
| 580 | } |
|---|
| 581 | |
|---|
| 582 | if($TotalDiscountCalculate > 0) { |
|---|
| 583 | if(isset($post['clickandpledge_coupon_code']) && $post['clickandpledge_coupon_code'] != '') { |
|---|
| 584 | $trans_coupon=$dom->createElement('CouponCode',$post['clickandpledge_coupon_code']); |
|---|
| 585 | $trans_coupon=$transation->appendChild($trans_coupon); |
|---|
| 586 | } |
|---|
| 587 | } |
|---|
| 588 | |
|---|
| 589 | $strParam =$dom->saveXML(); |
|---|
| 590 | //die(); |
|---|
| 591 | return $strParam; |
|---|
| 592 | } |
|---|
| 593 | |
|---|
| 594 | public function getEngine() { |
|---|
| 595 | return "clickandpledge_payment"; |
|---|
| 596 | } |
|---|
| 597 | public function getTitle() { |
|---|
| 598 | return "Click & Pledge"; |
|---|
| 599 | } |
|---|
| 600 | |
|---|
| 601 | public function getForm() |
|---|
| 602 | { |
|---|
| 603 | return "Config_ClickandPledge"; |
|---|
| 604 | } |
|---|
| 605 | |
|---|
| 606 | |
|---|
| 607 | |
|---|
| 608 | public function processTransaction() { |
|---|
| 609 | return array( |
|---|
| 610 | "external_id" => $this->_post['token'], |
|---|
| 611 | "paid" => $this->_post['clickandpledge_Amount']-$this->_post['clickandpledge_Discount'], |
|---|
| 612 | ); |
|---|
| 613 | } |
|---|
| 614 | public function bind(array $post, array $get) { |
|---|
| 615 | // this is a good place to set $this->data |
|---|
| 616 | $this->setObject(new Wpjb_Model_Payment($post["id"])); |
|---|
| 617 | parent::bind($post, $get); |
|---|
| 618 | } |
|---|
| 619 | private function getMerchant() { |
|---|
| 620 | $merchant = array(); |
|---|
| 621 | //USD Account |
|---|
| 622 | $merchant['wpjobboard_clickandpledge_usdaccount'] = $this->conf('wpjobboard_clickandpledge_usdaccount'); |
|---|
| 623 | $merchant['wpjobboard_clickandpledge_USD_AccountID'] = $this->conf('wpjobboard_clickandpledge_USD_AccountID'); |
|---|
| 624 | $merchant['wpjobboard_clickandpledge_USD_AccountGuid'] = $this->conf('wpjobboard_clickandpledge_USD_AccountGuid'); |
|---|
| 625 | $merchant['wpjobboard_clickandpledge_USD_OrderMode'] = $this->conf('wpjobboard_clickandpledge_USD_OrderMode'); |
|---|
| 626 | |
|---|
| 627 | //EUR Account |
|---|
| 628 | $merchant['wpjobboard_clickandpledge_euraccount'] = $this->conf('wpjobboard_clickandpledge_euraccount'); |
|---|
| 629 | $merchant['wpjobboard_clickandpledge_EUR_AccountID'] = $this->conf('wpjobboard_clickandpledge_EUR_AccountID'); |
|---|
| 630 | $merchant['wpjobboard_clickandpledge_EUR_AccountGuid'] = $this->conf('wpjobboard_clickandpledge_EUR_AccountGuid'); |
|---|
| 631 | $merchant['wpjobboard_clickandpledge_EUR_OrderMode'] = $this->conf('wpjobboard_clickandpledge_EUR_OrderMode'); |
|---|
| 632 | |
|---|
| 633 | //CAD Account |
|---|
| 634 | $merchant['wpjobboard_clickandpledge_cadaccount'] = $this->conf('wpjobboard_clickandpledge_cadaccount'); |
|---|
| 635 | $merchant['wpjobboard_clickandpledge_CAD_AccountID'] = $this->conf('wpjobboard_clickandpledge_CAD_AccountID'); |
|---|
| 636 | $merchant['wpjobboard_clickandpledge_CAD_AccountGuid'] = $this->conf('wpjobboard_clickandpledge_CAD_AccountGuid'); |
|---|
| 637 | $merchant['wpjobboard_clickandpledge_CAD_OrderMode'] = $this->conf('wpjobboard_clickandpledge_CAD_OrderMode'); |
|---|
| 638 | |
|---|
| 639 | //GBP Account |
|---|
| 640 | $merchant['wpjobboard_clickandpledge_gbpaccount'] = $this->conf('wpjobboard_clickandpledge_gbpaccount'); |
|---|
| 641 | $merchant['wpjobboard_clickandpledge_GBP_AccountID'] = $this->conf('wpjobboard_clickandpledge_GBP_AccountID'); |
|---|
| 642 | $merchant['wpjobboard_clickandpledge_GBP_AccountGuid'] = $this->conf('wpjobboard_clickandpledge_GBP_AccountGuid'); |
|---|
| 643 | $merchant['wpjobboard_clickandpledge_GBP_OrderMode'] = $this->conf('wpjobboard_clickandpledge_GBP_OrderMode'); |
|---|
| 644 | |
|---|
| 645 | //HKD Account |
|---|
| 646 | $merchant['wpjobboard_clickandpledge_hkdaccount'] = $this->conf('wpjobboard_clickandpledge_hkdaccount'); |
|---|
| 647 | $merchant['wpjobboard_clickandpledge_HKD_AccountID'] = $this->conf('wpjobboard_clickandpledge_HKD_AccountID'); |
|---|
| 648 | $merchant['wpjobboard_clickandpledge_HKD_AccountGuid'] = $this->conf('wpjobboard_clickandpledge_HKD_AccountGuid'); |
|---|
| 649 | $merchant['wpjobboard_clickandpledge_HKD_OrderMode'] = $this->conf('wpjobboard_clickandpledge_HKD_OrderMode'); |
|---|
| 650 | |
|---|
| 651 | //Payment Methods |
|---|
| 652 | $merchant['wpjobboard_clickandpledge_Paymentmethods'] = $this->conf('wpjobboard_clickandpledge_Paymentmethods'); |
|---|
| 653 | //Default Payment Method |
|---|
| 654 | $merchant['wpjobboard_clickandpledge_DefaultpaymentMethod'] = $this->conf('wpjobboard_clickandpledge_DefaultpaymentMethod'); |
|---|
| 655 | |
|---|
| 656 | //Receipt Settings |
|---|
| 657 | $merchant['wpjobboard_clickandpledge_emailcustomer'] = $this->conf('wpjobboard_clickandpledge_emailcustomer'); |
|---|
| 658 | $merchant['wpjobboard_clickandpledge_OrganizationInformation'] = $this->conf('wpjobboard_clickandpledge_OrganizationInformation'); |
|---|
| 659 | $merchant['wpjobboard_clickandpledge_TermsCondition'] = $this->conf('wpjobboard_clickandpledge_TermsCondition'); |
|---|
| 660 | |
|---|
| 661 | //Recurring Settings |
|---|
| 662 | $merchant['wpjobboard_clickandpledge_isRecurring'] = $this->conf('wpjobboard_clickandpledge_isRecurring'); |
|---|
| 663 | $merchant['wpjobboard_clickandpledge_RecurringLabel'] = $this->conf('wpjobboard_clickandpledge_RecurringLabel'); |
|---|
| 664 | $merchant['wpjobboard_clickandpledge_Periodicity'] = $this->conf('wpjobboard_clickandpledge_Periodicity'); |
|---|
| 665 | $merchant['wpjobboard_clickandpledge_RecurringMethod_Subscription'] = $this->conf('wpjobboard_clickandpledge_RecurringMethod_Subscription'); |
|---|
| 666 | $merchant['wpjobboard_clickandpledge_maxrecurrings_Subscription'] = $this->conf('wpjobboard_clickandpledge_maxrecurrings_Subscription'); |
|---|
| 667 | $merchant['wpjobboard_clickandpledge_RecurringMethod_Installment'] = $this->conf('wpjobboard_clickandpledge_RecurringMethod_Installment'); |
|---|
| 668 | $merchant['wpjobboard_clickandpledge_maxrecurrings_Installment'] = $this->conf('wpjobboard_clickandpledge_maxrecurrings_Installment'); |
|---|
| 669 | $merchant['wpjobboard_clickandpledge_indefinite'] = $this->conf('wpjobboard_clickandpledge_indefinite'); |
|---|
| 670 | return $merchant; |
|---|
| 671 | } |
|---|
| 672 | public function render() { |
|---|
| 673 | $data = $this->_data; |
|---|
| 674 | $id = $this->_data->id; |
|---|
| 675 | $availableCurrencies = array(); |
|---|
| 676 | $paymentMethods = array(); |
|---|
| 677 | $merchant = $this->getMerchant(); |
|---|
| 678 | |
|---|
| 679 | //echo '<pre>'; |
|---|
| 680 | //print_r($_POST); |
|---|
| 681 | if(isset($merchant['wpjobboard_clickandpledge_usdaccount']) && $merchant['wpjobboard_clickandpledge_usdaccount'] != '') |
|---|
| 682 | array_push($availableCurrencies, 'USD'); |
|---|
| 683 | if(isset($merchant['wpjobboard_clickandpledge_euraccount']) && $merchant['wpjobboard_clickandpledge_euraccount'] != '') |
|---|
| 684 | array_push($availableCurrencies, 'EUR'); |
|---|
| 685 | if(isset($merchant['wpjobboard_clickandpledge_cadaccount']) && $merchant['wpjobboard_clickandpledge_cadaccount'] != '') |
|---|
| 686 | array_push($availableCurrencies, 'CAD'); |
|---|
| 687 | if(isset($merchant['wpjobboard_clickandpledge_gbpaccount']) && $merchant['wpjobboard_clickandpledge_gbpaccount'] != '') |
|---|
| 688 | array_push($availableCurrencies, 'GBP'); |
|---|
| 689 | if(isset($merchant['wpjobboard_clickandpledge_hkdaccount']) && $merchant['wpjobboard_clickandpledge_hkdaccount'] != '') |
|---|
| 690 | array_push($availableCurrencies, 'HKD'); |
|---|
| 691 | |
|---|
| 692 | |
|---|
| 693 | $selectedCurrency = $this->_data->payment_currency; |
|---|
| 694 | if(in_array($selectedCurrency,$availableCurrencies)) { |
|---|
| 695 | if(isset($merchant['wpjobboard_clickandpledge_Paymentmethods']) && count($merchant['wpjobboard_clickandpledge_Paymentmethods']) > 0) { |
|---|
| 696 | foreach($merchant['wpjobboard_clickandpledge_Paymentmethods'] as $method) { |
|---|
| 697 | if($method == 'CreditCard') |
|---|
| 698 | $paymentMethods[$method] = 'Credit Card'; |
|---|
| 699 | if($method == 'eCheck') |
|---|
| 700 | $paymentMethods[$method] = 'eCheck'; |
|---|
| 701 | if($method == 'PurchaseOrder') |
|---|
| 702 | $paymentMethods[$method] = 'Purchase Order'; |
|---|
| 703 | if($method == 'Invoice') |
|---|
| 704 | $paymentMethods[$method] = 'Invoice'; |
|---|
| 705 | } |
|---|
| 706 | } |
|---|
| 707 | else { |
|---|
| 708 | $paymentMethods['CreditCard'] = 'Credit Card'; |
|---|
| 709 | $paymentMethods['eCheck'] = 'eCheck'; |
|---|
| 710 | $paymentMethods['PurchaseOrder'] = 'Purchase Order'; |
|---|
| 711 | $paymentMethods['Invoice'] = 'Invoice'; |
|---|
| 712 | } |
|---|
| 713 | |
|---|
| 714 | $defaultpayment = 'CreditCard'; |
|---|
| 715 | if($merchant['wpjobboard_clickandpledge_DefaultpaymentMethod'] != '') |
|---|
| 716 | $defaultpayment = $merchant['wpjobboard_clickandpledge_DefaultpaymentMethod']; |
|---|
| 717 | |
|---|
| 718 | |
|---|
| 719 | |
|---|
| 720 | $ajaxurl = admin_url("admin-ajax.php"); |
|---|
| 721 | |
|---|
| 722 | wp_register_script( 'clickandpledge-plugin-script', plugins_url( '/clickandpledge.js', __FILE__ ) ); |
|---|
| 723 | wp_enqueue_script( 'clickandpledge-plugin-script' ); |
|---|
| 724 | |
|---|
| 725 | wp_register_script( 'jquery.validate.min-script', plugins_url( '/jquery.validate.min.js', __FILE__ ) ); |
|---|
| 726 | wp_enqueue_script( 'jquery.validate.min-script' ); |
|---|
| 727 | |
|---|
| 728 | wp_register_script( 'clickandpledge_validations-script', plugins_url( '/clickandpledge_validations.js', __FILE__ ) ); |
|---|
| 729 | wp_enqueue_script( 'clickandpledge_validations-script' ); |
|---|
| 730 | $html = ' |
|---|
| 731 | <style type="text/css"> |
|---|
| 732 | .form-row > label > span { |
|---|
| 733 | display: block; |
|---|
| 734 | width: 200px; |
|---|
| 735 | float: left; |
|---|
| 736 | line-height: 2em; |
|---|
| 737 | } |
|---|
| 738 | .form-row label.error { |
|---|
| 739 | color: red; |
|---|
| 740 | font-style: italic; |
|---|
| 741 | } |
|---|
| 742 | </style> |
|---|
| 743 | <script type="text/javascript"> |
|---|
| 744 | var WPJB_PAYMENT_ID = '.$id.'; |
|---|
| 745 | if (typeof ajaxurl === "undefined") { |
|---|
| 746 | ajaxurl = "'.$ajaxurl.'"; |
|---|
| 747 | } |
|---|
| 748 | </script> |
|---|
| 749 | <form action="" method="POST" id="payment-form"> |
|---|
| 750 | <h3>'.__("Click & Pledge", "wpjobboard").'</h3> |
|---|
| 751 | <div class="payment-errors"></div> |
|---|
| 752 | <div class="htmlholder"> |
|---|
| 753 | '; |
|---|
| 754 | |
|---|
| 755 | if(count($paymentMethods) > 0) { |
|---|
| 756 | $html .= '<span style="width:980px" id="payment_methods">'; |
|---|
| 757 | foreach($paymentMethods as $pkey => $pval) { |
|---|
| 758 | if($pkey == $defaultpayment) { |
|---|
| 759 | $html .= '<input type="radio" id="cnp_payment_method_selection_'.$pkey.'" name="cnp_payment_method_selection" class="cnp_payment_method_selection" style="margin: 0 0 0 0;" value="'.$pkey.'" checked> <b>'.$pval.'</b> '; |
|---|
| 760 | } else { |
|---|
| 761 | $html .= '<input type="radio" id="cnp_payment_method_selection_'.$pkey.'" name="cnp_payment_method_selection" class="cnp_payment_method_selection" style="margin: 0 0 0 0;" value="'.$pkey.'"> <b>'.$pval.'</b> '; |
|---|
| 762 | } |
|---|
| 763 | } |
|---|
| 764 | $html .= '</span>'; |
|---|
| 765 | } |
|---|
| 766 | |
|---|
| 767 | $html .= '<script> |
|---|
| 768 | jQuery("#cnp_payment_method_selection_CreditCard").click(function(){ |
|---|
| 769 | jQuery("#cnp_CreditCard_div").show(); |
|---|
| 770 | jQuery("#cnp_eCheck_div").hide(); |
|---|
| 771 | jQuery("#cnp_Invoice_div").hide(); |
|---|
| 772 | jQuery("#cnp_PurchaseOrder_div").hide(); |
|---|
| 773 | |
|---|
| 774 | }); |
|---|
| 775 | jQuery("#cnp_payment_method_selection_eCheck").click(function(){ |
|---|
| 776 | jQuery("#cnp_CreditCard_div").hide(); |
|---|
| 777 | jQuery("#cnp_eCheck_div").show(); |
|---|
| 778 | jQuery("#cnp_Invoice_div").hide(); |
|---|
| 779 | jQuery("#cnp_PurchaseOrder_div").hide(); |
|---|
| 780 | |
|---|
| 781 | }); |
|---|
| 782 | jQuery("#cnp_payment_method_selection_Invoice").click(function(){ |
|---|
| 783 | jQuery("#cnp_CreditCard_div").hide(); |
|---|
| 784 | jQuery("#cnp_eCheck_div").hide(); |
|---|
| 785 | jQuery("#cnp_Invoice_div").show(); |
|---|
| 786 | jQuery("#cnp_PurchaseOrder_div").hide(); |
|---|
| 787 | |
|---|
| 788 | }); |
|---|
| 789 | jQuery("#cnp_payment_method_selection_PurchaseOrder").click(function(){ |
|---|
| 790 | jQuery("#cnp_CreditCard_div").hide(); |
|---|
| 791 | jQuery("#cnp_eCheck_div").hide(); |
|---|
| 792 | jQuery("#cnp_Invoice_div").hide(); |
|---|
| 793 | jQuery("#cnp_PurchaseOrder_div").show(); |
|---|
| 794 | |
|---|
| 795 | }); |
|---|
| 796 | </script>'; |
|---|
| 797 | $cdivdisplay = ($defaultpayment == 'CreditCard') ? 'block' : 'none'; |
|---|
| 798 | $recurringhtml = ''; |
|---|
| 799 | //echo $merchant['wpjobboard_clickandpledge_isRecurring'].'############'; |
|---|
| 800 | //die(); |
|---|
| 801 | if(isset($merchant['wpjobboard_clickandpledge_isRecurring']) && $merchant['wpjobboard_clickandpledge_isRecurring'] == 1) { |
|---|
| 802 | if($merchant['wpjobboard_clickandpledge_RecurringLabel'] != '') { |
|---|
| 803 | $recurringhtml .= '<br><div class="form-row" id="clickandpledge_isRecurring_div"> |
|---|
| 804 | <label> |
|---|
| 805 | <span>'.__($merchant['wpjobboard_clickandpledge_RecurringLabel'], "wpjobboard").'</span> |
|---|
| 806 | <input type="checkbox" name="clickandpledge_isRecurring" id="clickandpledge_isRecurring"/> |
|---|
| 807 | </label> |
|---|
| 808 | </div>'; |
|---|
| 809 | } else { |
|---|
| 810 | $recurringhtml .= '<br><div class="form-row" id="clickandpledge_isRecurring_div"> |
|---|
| 811 | <label> |
|---|
| 812 | <span>'.__('Is this Recurring Payment?', "wpjobboard").'</span> |
|---|
| 813 | <input type="checkbox" name="clickandpledge_isRecurring" id="clickandpledge_isRecurring"/> |
|---|
| 814 | </label> |
|---|
| 815 | </div>'; |
|---|
| 816 | } |
|---|
| 817 | $RecurringMethod = array(); |
|---|
| 818 | if(isset($merchant['wpjobboard_clickandpledge_RecurringMethod_Subscription']) && is_array($merchant['wpjobboard_clickandpledge_RecurringMethod_Subscription']) && count($merchant['wpjobboard_clickandpledge_RecurringMethod_Subscription']) > 0) { |
|---|
| 819 | array_push($RecurringMethod, 'Subscription'); |
|---|
| 820 | } |
|---|
| 821 | if(isset($merchant['wpjobboard_clickandpledge_RecurringMethod_Installment']) && is_array($merchant['wpjobboard_clickandpledge_RecurringMethod_Installment']) && count($merchant['wpjobboard_clickandpledge_RecurringMethod_Installment']) > 0) { |
|---|
| 822 | array_push($RecurringMethod, 'Installment'); |
|---|
| 823 | } |
|---|
| 824 | if(count($RecurringMethod) == 0) { |
|---|
| 825 | array_push($RecurringMethod, 'Subscription'); |
|---|
| 826 | array_push($RecurringMethod, 'Installment'); |
|---|
| 827 | } |
|---|
| 828 | if(count($RecurringMethod) > 0) { |
|---|
| 829 | if(count($RecurringMethod) == 1) { |
|---|
| 830 | $recurringhtml .= '<input type="hidden" name="clickandpledge_RecurringMethod" id="clickandpledge_RecurringMethod" value="'.$RecurringMethod[0].'">'; |
|---|
| 831 | } else { |
|---|
| 832 | $recurringhtml .= '<br><div class="form-row" id="clickandpledge_RecurringMethod_div"> |
|---|
| 833 | <label> |
|---|
| 834 | <span>'.__("Recurring Method", "wpjobboard").'</span> |
|---|
| 835 | <select id="clickandpledge_RecurringMethod" name="clickandpledge_RecurringMethod">'; |
|---|
| 836 | foreach ($RecurringMethod as $r) { |
|---|
| 837 | $recurringhtml .= '<option value="'.$r.'">'.$r.'</option>'; |
|---|
| 838 | } |
|---|
| 839 | $recurringhtml .= '</select> |
|---|
| 840 | </label> |
|---|
| 841 | </div>'; |
|---|
| 842 | } |
|---|
| 843 | } else { |
|---|
| 844 | $recurringhtml .= '<div class="form-row" id="clickandpledge_RecurringMethod_div"> |
|---|
| 845 | <label> |
|---|
| 846 | <span>'.__("Recurring Method", "wpjobboard").'</span> |
|---|
| 847 | <select id="clickandpledge_RecurringMethod" name="clickandpledge_RecurringMethod"> |
|---|
| 848 | <option value="Subscription">Subscription</option> |
|---|
| 849 | <option value="Installment">Installment</option> |
|---|
| 850 | </select> |
|---|
| 851 | </label> |
|---|
| 852 | </div>'; |
|---|
| 853 | } |
|---|
| 854 | |
|---|
| 855 | if(isset($merchant['wpjobboard_clickandpledge_indefinite']) && is_array($merchant['wpjobboard_clickandpledge_indefinite']) && count($merchant['wpjobboard_clickandpledge_indefinite']) > 0) { |
|---|
| 856 | $recurringhtml .= '<br><div class="form-row" id="clickandpledge_indefinite_div"> |
|---|
| 857 | <label> |
|---|
| 858 | <span>'.__("Indefinite Recurring", "wpjobboard").'</span> |
|---|
| 859 | <input type="checkbox" name="clickandpledge_indefinite" id="clickandpledge_indefinite"/> |
|---|
| 860 | </label> |
|---|
| 861 | </div>'; |
|---|
| 862 | } |
|---|
| 863 | |
|---|
| 864 | if(isset($merchant['wpjobboard_clickandpledge_Periodicity']) && is_array($merchant['wpjobboard_clickandpledge_Periodicity']) && count($merchant['wpjobboard_clickandpledge_Periodicity']) > 0) { |
|---|
| 865 | $recurringhtml .= '<br><div class="form-row" id="clickandpledge_Periodicity_div"> |
|---|
| 866 | <label> |
|---|
| 867 | <span>'.__("Every", "wpjobboard").'</span> |
|---|
| 868 | <select id="clickandpledge_Periodicity" name="clickandpledge_Periodicity">'; |
|---|
| 869 | foreach ($merchant['wpjobboard_clickandpledge_Periodicity'] as $r) { |
|---|
| 870 | $recurringhtml .= '<option value="'.$r.'">'.$r.'</option>'; |
|---|
| 871 | } |
|---|
| 872 | $recurringhtml .= '</select> |
|---|
| 873 | </label> |
|---|
| 874 | <span id="clickandpledge_Installment_div"><input type="text" name="clickandpledge_Installment" id="clickandpledge_Installment" class="required" title="Installments" style="width:100px;" maxlength="3"/> <font color="#FF0000">*</font> payments</span> |
|---|
| 875 | </div> |
|---|
| 876 | <script> |
|---|
| 877 | jQuery("#clickandpledge_Installment").keypress(function(e) { |
|---|
| 878 | var a = []; |
|---|
| 879 | var k = e.which; |
|---|
| 880 | |
|---|
| 881 | for (i = 48; i < 58; i++) |
|---|
| 882 | a.push(i); |
|---|
| 883 | |
|---|
| 884 | if (!(a.indexOf(k)>=0)) |
|---|
| 885 | e.preventDefault(); |
|---|
| 886 | }); |
|---|
| 887 | </script>'; |
|---|
| 888 | } else { |
|---|
| 889 | $Periodicity = array(); |
|---|
| 890 | $Periodicity['Week'] = 'Week'; |
|---|
| 891 | $Periodicity['2 Weeks'] = '2 Weeks'; |
|---|
| 892 | $Periodicity['Month'] = 'Month'; |
|---|
| 893 | $Periodicity['2 Months'] = '2 Months'; |
|---|
| 894 | $Periodicity['Quarter'] = 'Quarter'; |
|---|
| 895 | $Periodicity['6 Months'] = '6 Months'; |
|---|
| 896 | $Periodicity['Year'] = 'Year'; |
|---|
| 897 | $recurringhtml .= '<br><div class="form-row" id="clickandpledge_Periodicity_div"> |
|---|
| 898 | <label> |
|---|
| 899 | <span>'.__("Every", "wpjobboard").'</span> |
|---|
| 900 | <select id="clickandpledge_Periodicity" name="clickandpledge_Periodicity">'; |
|---|
| 901 | foreach ($Periodicity as $k => $v) { |
|---|
| 902 | $recurringhtml .= '<option value="'.$k.'">'.$v.'</option>'; |
|---|
| 903 | } |
|---|
| 904 | $recurringhtml .= '</select> |
|---|
| 905 | </label> |
|---|
| 906 | <span id="clickandpledge_Installment_div"><input type="text" name="clickandpledge_Installment" id="clickandpledge_Installment" class="required" title="Installments" style="width:100px;" maxlength="3"/> <font color="#FF0000">*</font> payments</span> |
|---|
| 907 | </div> |
|---|
| 908 | <script> |
|---|
| 909 | jQuery("#clickandpledge_Installment").keypress(function(e) { |
|---|
| 910 | var a = []; |
|---|
| 911 | var k = e.which; |
|---|
| 912 | |
|---|
| 913 | for (i = 48; i < 58; i++) |
|---|
| 914 | a.push(i); |
|---|
| 915 | |
|---|
| 916 | if (!(a.indexOf(k)>=0)) |
|---|
| 917 | e.preventDefault(); |
|---|
| 918 | }); |
|---|
| 919 | </script>'; |
|---|
| 920 | } |
|---|
| 921 | |
|---|
| 922 | } |
|---|
| 923 | //echo $recurringhtml; |
|---|
| 924 | //die('333333333333'); |
|---|
| 925 | $clickandpledgename_CreditCard = '<div class="form-row cnp_payment_style" > |
|---|
| 926 | <label> |
|---|
| 927 | <span>'.__("Name <font color='red'>*</font>", "wpjobboard").'</span> |
|---|
| 928 | <input type="text" size="20" data-clickandpledge="number" name="clickandpledge_FirstName_CreditCard" id="clickandpledge_FirstName_CreditCard" class="required NameOnCard" placeholder="First Name"/> |
|---|
| 929 | <input type="text" size="20" data-clickandpledge="number" name="clickandpledge_LastName_CreditCard" id="clickandpledge_LastName_CreditCard" class="required NameOnCard" placeholder="Last Name"/> |
|---|
| 930 | </label> |
|---|
| 931 | </div> |
|---|
| 932 | <style> |
|---|
| 933 | .cnp_payment_style label span{ |
|---|
| 934 | width: 100%; |
|---|
| 935 | } |
|---|
| 936 | #clickandpledge_FirstName_CreditCard, #clickandpledge_LastName_CreditCard { |
|---|
| 937 | width: 48%; |
|---|
| 938 | display: inline-block; |
|---|
| 939 | } |
|---|
| 940 | </style> |
|---|
| 941 | '; |
|---|
| 942 | $clickandpledgename_eCheck = '<div class="form-row cnp_payment_style" > |
|---|
| 943 | <label> |
|---|
| 944 | <span>'.__("Name <font color='red'>*</font>", "wpjobboard").'</span> |
|---|
| 945 | <input type="text" size="20" data-clickandpledge="number" name="clickandpledge_FirstName_eCheck" id="clickandpledge_FirstName_eCheck" class="required NameOnCard" placeholder="First Name"/> |
|---|
| 946 | <input type="text" size="20" data-clickandpledge="number" name="clickandpledge_LastName_eCheck" id="clickandpledge_LastName_eCheck" class="required NameOnCard" placeholder="Last Name"/> |
|---|
| 947 | </label> |
|---|
| 948 | </div> |
|---|
| 949 | <style> |
|---|
| 950 | .cnp_payment_style label span{ |
|---|
| 951 | width: 100%; |
|---|
| 952 | } |
|---|
| 953 | #clickandpledge_FirstName_eCheck, #clickandpledge_LastName_eCheck { |
|---|
| 954 | width: 48%; |
|---|
| 955 | display: inline-block; |
|---|
| 956 | } |
|---|
| 957 | </style> |
|---|
| 958 | '; |
|---|
| 959 | $clickandpledgename_Invoice = '<div class="form-row cnp_payment_style" > |
|---|
| 960 | <label> |
|---|
| 961 | <span>'.__("Name <font color='red'>*</font>", "wpjobboard").'</span> |
|---|
| 962 | <input type="text" size="20" data-clickandpledge="number" name="clickandpledge_FirstName_Invoice" id="clickandpledge_FirstName_Invoice" class="required NameOnCard" placeholder="First Name"/> |
|---|
| 963 | <input type="text" size="20" data-clickandpledge="number" name="clickandpledge_LastName_Invoice" id="clickandpledge_LastName_Invoice" class="required NameOnCard" placeholder="Last Name"/> |
|---|
| 964 | </label> |
|---|
| 965 | </div> |
|---|
| 966 | <style> |
|---|
| 967 | .cnp_payment_style label span{ |
|---|
| 968 | width: 100%; |
|---|
| 969 | } |
|---|
| 970 | #clickandpledge_FirstName_Invoice, #clickandpledge_LastName_Invoice { |
|---|
| 971 | width: 48%; |
|---|
| 972 | display: inline-block; |
|---|
| 973 | } |
|---|
| 974 | </style> '; |
|---|
| 975 | $clickandpledgename_PO = '<div class="form-row cnp_payment_style" > |
|---|
| 976 | <label> |
|---|
| 977 | <span>'.__("Name <font color='red'>*</font>", "wpjobboard").'</span> |
|---|
| 978 | <input type="text" size="20" data-clickandpledge="number" name="clickandpledge_FirstName_PO" id="clickandpledge_FirstName_PO" class="required NameOnCard" placeholder="First Name"/> |
|---|
| 979 | <input type="text" size="20" data-clickandpledge="number" name="clickandpledge_LastName_PO" id="clickandpledge_LastName_PO" class="required NameOnCard" placeholder="Last Name"/> |
|---|
| 980 | </label> |
|---|
| 981 | </div> |
|---|
| 982 | <style> |
|---|
| 983 | .cnp_payment_style label span{ |
|---|
| 984 | width: 100%; |
|---|
| 985 | } |
|---|
| 986 | #clickandpledge_FirstName_PO, #clickandpledge_LastName_PO { |
|---|
| 987 | width: 48%; |
|---|
| 988 | display: inline-block; |
|---|
| 989 | } |
|---|
| 990 | </style> '; |
|---|
| 991 | |
|---|
| 992 | $html .= '<div style="display:'.$cdivdisplay.'" id="cnp_CreditCard_div">'; |
|---|
| 993 | $html .= $clickandpledgename_CreditCard; |
|---|
| 994 | $html .= '<div class="form-row"> |
|---|
| 995 | <label> |
|---|
| 996 | <span>'.__("Name On Card <font color='red'>*</font>", "wpjobboard").'</span> |
|---|
| 997 | <input type="text" size="20" data-clickandpledge="number" name="clickandpledge_nameOnCard" id="clickandpledge_nameOnCard" class="required NameOnCard" placeholder="Name On Card"/> |
|---|
| 998 | </label> |
|---|
| 999 | </div> |
|---|
| 1000 | |
|---|
| 1001 | <div class="form-row"> |
|---|
| 1002 | <label> |
|---|
| 1003 | <span>'.__("Card Number <font color='red'>*</font>", "wpjobboard").'</span> |
|---|
| 1004 | <input type="text" size="20" data-clickandpledge="number" name="clickandpledge_cardNumber" id="clickandpledge_cardNumber" class="required creditcard" placeholder="Card Number"/> |
|---|
| 1005 | </label> |
|---|
| 1006 | </div> |
|---|
| 1007 | |
|---|
| 1008 | <div class="form-row"> |
|---|
| 1009 | <label> |
|---|
| 1010 | <span>'.__("CVV <font color='red'>*</font>", "wpjobboard").'</span> |
|---|
| 1011 | <input type="text" size="4" data-clickandpledge="cvc" maxlength="4" name="clickandpledge_cvc" id="clickandpledge_cvc" class="required Cvv2" placeholder="CVV"/> |
|---|
| 1012 | </label> |
|---|
| 1013 | </div> |
|---|
| 1014 | <div class="form-row"> |
|---|
| 1015 | <label><span>'.__("Expiration (MM/YYYY) <font color='red'>*</font>", "wpjobboard").'</span></label> |
|---|
| 1016 | <select name="clickandpledge_cardExpMonth" id="clickandpledge_cardExpMonth" class="required">'.$this->getMonths().'</select> |
|---|
| 1017 | <span> / </span> |
|---|
| 1018 | <select name="clickandpledge_cardExpYear" id="clickandpledge_cardExpYear" class="required" data-clickandpledge="exp-year">'.$this->getYears().'</select> |
|---|
| 1019 | </div>'; |
|---|
| 1020 | $html .= $recurringhtml; |
|---|
| 1021 | $html .= '</div>'; //CreditCard Div End |
|---|
| 1022 | |
|---|
| 1023 | $eCheckdivdisplay = ($defaultpayment == 'eCheck') ? 'block' : 'none'; |
|---|
| 1024 | $recurringhtml_eCheck = ''; |
|---|
| 1025 | |
|---|
| 1026 | if(isset($merchant['wpjobboard_clickandpledge_isRecurring']) && $merchant['wpjobboard_clickandpledge_isRecurring'] == 1) { |
|---|
| 1027 | if($merchant['wpjobboard_clickandpledge_RecurringLabel'] != '') { |
|---|
| 1028 | $recurringhtml_eCheck .= '<br><div class="form-row" id="clickandpledge_isRecurring_div_eCheck"> |
|---|
| 1029 | <label> |
|---|
| 1030 | <span>'.__($merchant['wpjobboard_clickandpledge_RecurringLabel'], "wpjobboard").'</span> |
|---|
| 1031 | <input type="checkbox" name="clickandpledge_isRecurring_eCheck" id="clickandpledge_isRecurring_eCheck"/> |
|---|
| 1032 | </label> |
|---|
| 1033 | </div>'; |
|---|
| 1034 | } else { |
|---|
| 1035 | $recurringhtml_eCheck .= '<br><div class="form-row" id="clickandpledge_isRecurring_div_eCheck"> |
|---|
| 1036 | <label> |
|---|
| 1037 | <span>'.__('Is this Recurring Payment?', "wpjobboard").'</span> |
|---|
| 1038 | <input type="checkbox" name="clickandpledge_isRecurring_eCheck" id="clickandpledge_isRecurring_eCheck"/> |
|---|
| 1039 | </label> |
|---|
| 1040 | </div>'; |
|---|
| 1041 | } |
|---|
| 1042 | $RecurringMethod = array(); |
|---|
| 1043 | if(isset($merchant['wpjobboard_clickandpledge_RecurringMethod_Subscription']) && is_array($merchant['wpjobboard_clickandpledge_RecurringMethod_Subscription']) && count($merchant['wpjobboard_clickandpledge_RecurringMethod_Subscription']) > 0) { |
|---|
| 1044 | array_push($RecurringMethod, 'Subscription'); |
|---|
| 1045 | } |
|---|
| 1046 | if(isset($merchant['wpjobboard_clickandpledge_RecurringMethod_Installment']) && is_array($merchant['wpjobboard_clickandpledge_RecurringMethod_Installment']) && count($merchant['wpjobboard_clickandpledge_RecurringMethod_Installment']) > 0) { |
|---|
| 1047 | array_push($RecurringMethod, 'Installment'); |
|---|
| 1048 | } |
|---|
| 1049 | if(count($RecurringMethod) == 0) { |
|---|
| 1050 | array_push($RecurringMethod, 'Subscription'); |
|---|
| 1051 | array_push($RecurringMethod, 'Installment'); |
|---|
| 1052 | } |
|---|
| 1053 | if(count($RecurringMethod) > 0) { |
|---|
| 1054 | if(count($RecurringMethod) == 1) { |
|---|
| 1055 | $recurringhtml_eCheck .= '<input type="hidden" name="clickandpledge_RecurringMethod_eCheck" id="clickandpledge_RecurringMethod_eCheck" value="'.$RecurringMethod[0].'">'; |
|---|
| 1056 | } else { |
|---|
| 1057 | $recurringhtml_eCheck .= '<br><div class="form-row" id="clickandpledge_RecurringMethod_div_eCheck"> |
|---|
| 1058 | <label> |
|---|
| 1059 | <span>'.__("Recurring Method", "wpjobboard").'</span> |
|---|
| 1060 | <select id="clickandpledge_RecurringMethod_eCheck" name="clickandpledge_RecurringMethod_eCheck">'; |
|---|
| 1061 | foreach ($RecurringMethod as $r) { |
|---|
| 1062 | $recurringhtml_eCheck .= '<option value="'.$r.'">'.$r.'</option>'; |
|---|
| 1063 | } |
|---|
| 1064 | $recurringhtml_eCheck .= '</select> |
|---|
| 1065 | </label> |
|---|
| 1066 | </div>'; |
|---|
| 1067 | } |
|---|
| 1068 | } else { |
|---|
| 1069 | $recurringhtml_eCheck .= '<div class="form-row" id="clickandpledge_RecurringMethod_div_eCheck"> |
|---|
| 1070 | <label> |
|---|
| 1071 | <span>'.__("Recurring Method", "wpjobboard").'</span> |
|---|
| 1072 | <select id="clickandpledge_RecurringMethod_eCheck" name="clickandpledge_RecurringMethod_eCheck"> |
|---|
| 1073 | <option value="Subscription">Subscription</option> |
|---|
| 1074 | <option value="Installment">Installment</option> |
|---|
| 1075 | </select> |
|---|
| 1076 | </label> |
|---|
| 1077 | </div>'; |
|---|
| 1078 | } |
|---|
| 1079 | |
|---|
| 1080 | if(isset($merchant['wpjobboard_clickandpledge_indefinite']) && is_array($merchant['wpjobboard_clickandpledge_indefinite']) && count($merchant['wpjobboard_clickandpledge_indefinite']) > 0) { |
|---|
| 1081 | $recurringhtml_eCheck .= '<br><div class="form-row" id="clickandpledge_indefinite_div_eCheck"> |
|---|
| 1082 | <label> |
|---|
| 1083 | <span>'.__("Indefinite Recurring", "wpjobboard").'</span> |
|---|
| 1084 | <input type="checkbox" name="clickandpledge_indefinite_eCheck" id="clickandpledge_indefinite_eCheck"/> |
|---|
| 1085 | </label> |
|---|
| 1086 | </div>'; |
|---|
| 1087 | } |
|---|
| 1088 | |
|---|
| 1089 | if(isset($merchant['wpjobboard_clickandpledge_Periodicity']) && is_array($merchant['wpjobboard_clickandpledge_Periodicity']) && count($merchant['wpjobboard_clickandpledge_Periodicity']) > 0) { |
|---|
| 1090 | $recurringhtml_eCheck .= '<br><div class="form-row" id="clickandpledge_Periodicity_div_eCheck"> |
|---|
| 1091 | <label> |
|---|
| 1092 | <span>'.__("Every", "wpjobboard").'</span> |
|---|
| 1093 | <select id="clickandpledge_Periodicity_eCheck" name="clickandpledge_Periodicity_eCheck">'; |
|---|
| 1094 | foreach ($merchant['wpjobboard_clickandpledge_Periodicity'] as $r) { |
|---|
| 1095 | $recurringhtml_eCheck .= '<option value="'.$r.'">'.$r.'</option>'; |
|---|
| 1096 | } |
|---|
| 1097 | $recurringhtml_eCheck .= '</select> |
|---|
| 1098 | </label> |
|---|
| 1099 | <span id="clickandpledge_Installment_div_eCheck"><input type="text" name="clickandpledge_Installment_eCheck" id="clickandpledge_Installment_eCheck" class="required" title="Installments" style="width:100px;" maxlength="3"/> <font color="#FF0000">*</font> payments</span> |
|---|
| 1100 | </div> |
|---|
| 1101 | <script> |
|---|
| 1102 | jQuery("#clickandpledge_Installment_eCheck").keypress(function(e) { |
|---|
| 1103 | var a = []; |
|---|
| 1104 | var k = e.which; |
|---|
| 1105 | |
|---|
| 1106 | for (i = 48; i < 58; i++) |
|---|
| 1107 | a.push(i); |
|---|
| 1108 | |
|---|
| 1109 | if (!(a.indexOf(k)>=0)) |
|---|
| 1110 | e.preventDefault(); |
|---|
| 1111 | }); |
|---|
| 1112 | </script>'; |
|---|
| 1113 | } else { |
|---|
| 1114 | $Periodicity = array(); |
|---|
| 1115 | $Periodicity['Week'] = 'Week'; |
|---|
| 1116 | $Periodicity['2 Weeks'] = '2 Weeks'; |
|---|
| 1117 | $Periodicity['Month'] = 'Month'; |
|---|
| 1118 | $Periodicity['2 Months'] = '2 Months'; |
|---|
| 1119 | $Periodicity['Quarter'] = 'Quarter'; |
|---|
| 1120 | $Periodicity['6 Months'] = '6 Months'; |
|---|
| 1121 | $Periodicity['Year'] = 'Year'; |
|---|
| 1122 | $recurringhtml_eCheck .= '<br><div class="form-row" id="clickandpledge_Periodicity_div_eCheck"> |
|---|
| 1123 | <label> |
|---|
| 1124 | <span>'.__("Every", "wpjobboard").'</span> |
|---|
| 1125 | <select id="clickandpledge_Periodicity_eCheck" name="clickandpledge_Periodicity_eCheck">'; |
|---|
| 1126 | foreach ($Periodicity as $k => $v) { |
|---|
| 1127 | $recurringhtml_eCheck .= '<option value="'.$k.'">'.$v.'</option>'; |
|---|
| 1128 | } |
|---|
| 1129 | $recurringhtml_eCheck .= '</select> |
|---|
| 1130 | </label> |
|---|
| 1131 | <span id="clickandpledge_Installment_div_eCheck"><input type="text" name="clickandpledge_Installment_eCheck" id="clickandpledge_Installment_eCheck" class="required" title="Installments" style="width:100px;" maxlength="3"/> <font color="#FF0000">*</font> payments</span> |
|---|
| 1132 | </div> |
|---|
| 1133 | <script> |
|---|
| 1134 | jQuery("#clickandpledge_Installment_eCheck").keypress(function(e) { |
|---|
| 1135 | var a = []; |
|---|
| 1136 | var k = e.which; |
|---|
| 1137 | |
|---|
| 1138 | for (i = 48; i < 58; i++) |
|---|
| 1139 | a.push(i); |
|---|
| 1140 | |
|---|
| 1141 | if (!(a.indexOf(k)>=0)) |
|---|
| 1142 | e.preventDefault(); |
|---|
| 1143 | }); |
|---|
| 1144 | </script>'; |
|---|
| 1145 | } |
|---|
| 1146 | |
|---|
| 1147 | } |
|---|
| 1148 | $html .= '<div style="display:'.$eCheckdivdisplay.'" id="cnp_eCheck_div">'; |
|---|
| 1149 | $html .= $clickandpledgename_eCheck; |
|---|
| 1150 | $html .= ' |
|---|
| 1151 | <div class="form-row"> |
|---|
| 1152 | <label> |
|---|
| 1153 | <span>'.__("Routing Number <font color='red'>*</font>", "wpjobboard").'</span> |
|---|
| 1154 | <input type="text" data-clickandpledge="number" name="clickandpledge_echeck_RoutingNumber" id="clickandpledge_echeck_RoutingNumber" class="required RoutingNumber" placeholder="Routing Number"/> |
|---|
| 1155 | </label> |
|---|
| 1156 | </div> |
|---|
| 1157 | <div class="form-row"> |
|---|
| 1158 | <label> |
|---|
| 1159 | <span>'.__("Check Number <font color='red'>*</font>", "wpjobboard").'</span> |
|---|
| 1160 | <input type="text" data-clickandpledge="number" name="clickandpledge_echeck_CheckNumber" id="clickandpledge_echeck_CheckNumber" class="required CheckNumber" placeholder="Check Number"/> |
|---|
| 1161 | </label> |
|---|
| 1162 | </div> |
|---|
| 1163 | <div class="form-row"> |
|---|
| 1164 | <label> |
|---|
| 1165 | <span>'.__("Account Number <font color='red'>*</font>", "wpjobboard").'</span> |
|---|
| 1166 | <input type="text" data-clickandpledge="number" name="clickandpledge_echeck_AccountNumber" id="clickandpledge_echeck_AccountNumber" class="required AccountNumber" placeholder="Account Number"/> |
|---|
| 1167 | </label> |
|---|
| 1168 | </div> |
|---|
| 1169 | <div class="form-row"> |
|---|
| 1170 | <label> |
|---|
| 1171 | <span>'.__("Retype Account Number <font color='red'>*</font>", "wpjobboard").'</span> |
|---|
| 1172 | <input type="text" data-clickandpledge="number" name="clickandpledge_echeck_retypeAccountNumber" id="clickandpledge_echeck_retypeAccountNumber" class="required AccountNumber" placeholder="Retype Account Number"/> |
|---|
| 1173 | </label> |
|---|
| 1174 | </div> |
|---|
| 1175 | <div class="form-row"> |
|---|
| 1176 | <label> |
|---|
| 1177 | <span>'.__("Account Type <font color='red'>*</font>", "wpjobboard").'</span> |
|---|
| 1178 | <select name="clickandpledge_echeck_AccountType" id="clickandpledge_echeck_AccountType" title="Account Type"> |
|---|
| 1179 | <option value="SavingsAccount">SavingsAccount</option> |
|---|
| 1180 | <option value="CheckingAccount">CheckingAccount</option> |
|---|
| 1181 | </select> |
|---|
| 1182 | </label> |
|---|
| 1183 | </div> |
|---|
| 1184 | <div class="form-row"> |
|---|
| 1185 | <label> |
|---|
| 1186 | <span>'.__("Check Type <font color='red'>*</font>", "wpjobboard").'</span> |
|---|
| 1187 | <select name="clickandpledge_echeck_CheckType" id="clickandpledge_echeck_CheckType" title="Check Type"> |
|---|
| 1188 | <option value="Company">Company</option> |
|---|
| 1189 | <option value="Personal">Personal</option> |
|---|
| 1190 | </select> |
|---|
| 1191 | </label> |
|---|
| 1192 | </div> |
|---|
| 1193 | <div class="form-row"> |
|---|
| 1194 | <label> |
|---|
| 1195 | <span>'.__("Name on Account <font color='red'>*</font>", "wpjobboard").'</span> |
|---|
| 1196 | <input type="text" data-clickandpledge="number" name="clickandpledge_echeck_NameOnAccount" id="clickandpledge_echeck_NameOnAccount" class="required AccountNumber" placeholder="Name on Account"/> |
|---|
| 1197 | </label> |
|---|
| 1198 | </div> |
|---|
| 1199 | <div class="form-row"> |
|---|
| 1200 | <label> |
|---|
| 1201 | <span>'.__("Type of ID <font color='red'>*</font>", "wpjobboard").'</span> |
|---|
| 1202 | <select name="clickandpledge_echeck_IdType" id="clickandpledge_echeck_IdType" title="Type of ID"> |
|---|
| 1203 | <option value="Driver">Driver</option> |
|---|
| 1204 | <option value="Military">Military</option> |
|---|
| 1205 | <option value="State">State</option> |
|---|
| 1206 | </select> |
|---|
| 1207 | </label> |
|---|
| 1208 | </div>'; |
|---|
| 1209 | $html .= $recurringhtml_eCheck; |
|---|
| 1210 | $html .= '</div>'; //eCheck Div End |
|---|
| 1211 | |
|---|
| 1212 | $Invoicedivdisplay = ($defaultpayment == 'Invoice') ? 'block' : 'none'; |
|---|
| 1213 | $html .= '<div style="display:'.$Invoicedivdisplay.'" id="cnp_Invoice_div">'; |
|---|
| 1214 | $html .= $clickandpledgename_Invoice; |
|---|
| 1215 | $html .= ' |
|---|
| 1216 | <div class="form-row"> |
|---|
| 1217 | <label> |
|---|
| 1218 | <span>'.__("Invoice Number", "wpjobboard").'</span> |
|---|
| 1219 | <input type="text" data-clickandpledge="number" name="clickandpledge_Invoice_InvoiceNumber" id="clickandpledge_Invoice_InvoiceNumber" class="InvoiceCheckNumber" placeholder="Invoice Number"/> |
|---|
| 1220 | </label> |
|---|
| 1221 | </div>'; |
|---|
| 1222 | $html .= '</div>'; //Invoice Div End |
|---|
| 1223 | |
|---|
| 1224 | $PurchaseOrderdivdisplay = ($defaultpayment == 'PurchaseOrder') ? 'block' : 'none'; |
|---|
| 1225 | $html .= '<div style="display:'.$PurchaseOrderdivdisplay.'" id="cnp_PurchaseOrder_div">'; |
|---|
| 1226 | $html .= $clickandpledgename_PO; |
|---|
| 1227 | $html .= ' |
|---|
| 1228 | <div class="form-row"> |
|---|
| 1229 | <label> |
|---|
| 1230 | <span>'.__("Purchase Order Number", "wpjobboard").'</span> |
|---|
| 1231 | <input type="text" data-clickandpledge="number" name="clickandpledge_PurchaseOrder_OrderNumber" id="clickandpledge_PurchaseOrder_OrderNumber" class="PurchaseOrderNumber" placeholder="Purchase Order Number"/> |
|---|
| 1232 | </label> |
|---|
| 1233 | </div>'; |
|---|
| 1234 | $html .= '</div>'; //PurchaseOrder Div End |
|---|
| 1235 | $listing_id = ''; |
|---|
| 1236 | if(isset($_POST['listing']) && $_POST['listing'] != '') |
|---|
| 1237 | $listing_id = $_POST['listing']; |
|---|
| 1238 | elseif(isset($_POST['listing_type']) && $_POST['listing_type'] != '') |
|---|
| 1239 | $listing_id = $_POST['listing_type']; |
|---|
| 1240 | $varArray = array( |
|---|
| 1241 | 'clickandpledge_AccountID'=>$merchant['wpjobboard_clickandpledge_'.$selectedCurrency.'_AccountID'], |
|---|
| 1242 | 'clickandpledge_AccountGuid'=>$merchant['wpjobboard_clickandpledge_'.$selectedCurrency.'_AccountGuid'], |
|---|
| 1243 | 'clickandpledge_OrderMode' => $merchant['wpjobboard_clickandpledge_'.$selectedCurrency.'_OrderMode'], |
|---|
| 1244 | 'clickandpledge_Amount' => $this->_data->payment_sum+$this->_data->payment_discount, |
|---|
| 1245 | 'clickandpledge_Discount' => $this->_data->payment_discount, |
|---|
| 1246 | 'clickandpledge_OrganizationInformation' => htmlspecialchars($merchant['wpjobboard_clickandpledge_OrganizationInformation']), |
|---|
| 1247 | 'clickandpledge_TermsCondition' => htmlspecialchars($merchant['wpjobboard_clickandpledge_TermsCondition']), |
|---|
| 1248 | 'clickandpledge_email_customer' => (is_array($merchant['wpjobboard_clickandpledge_emailcustomer']) && count($merchant['wpjobboard_clickandpledge_emailcustomer']) > 0) ? $merchant['wpjobboard_clickandpledge_emailcustomer'][0] : '', |
|---|
| 1249 | 'clickandpledge_maxrecurrings_Subscription' => $merchant['wpjobboard_clickandpledge_maxrecurrings_Subscription'], |
|---|
| 1250 | 'clickandpledge_maxrecurrings_Installment' => $merchant['wpjobboard_clickandpledge_maxrecurrings_Installment'], |
|---|
| 1251 | 'clickandpledge_listing_id' => $listing_id, |
|---|
| 1252 | 'clickandpledge_coupon_code' => (isset($_POST['coupon'])) ? $_POST['coupon'] : '', |
|---|
| 1253 | ); |
|---|
| 1254 | foreach($varArray as $k=>$v) |
|---|
| 1255 | { |
|---|
| 1256 | $html.= '<input type="hidden" name="'.$k.'" id="'.$k.'" value="'.$v.'" />'; |
|---|
| 1257 | } |
|---|
| 1258 | $html .= '<button type="submit">'.__("Submit Payment", "wpjobboard").'</button> |
|---|
| 1259 | </div> |
|---|
| 1260 | </form>'; |
|---|
| 1261 | } else { |
|---|
| 1262 | if(count($availableCurrencies) > 0) { |
|---|
| 1263 | $html = 'Selected currency <b>'.$selectedCurrency.'</b> not supported by Click & Pledge. We are supporting <b>'.implode(',', $availableCurrencies).'</b> only. Please contact administrator.'; |
|---|
| 1264 | } else { |
|---|
| 1265 | $html = 'Selected currency <b>'.$selectedCurrency.'</b> not supported by Click & Pledge. Please contact administrator.'; |
|---|
| 1266 | } |
|---|
| 1267 | } |
|---|
| 1268 | return $html; |
|---|
| 1269 | } |
|---|
| 1270 | public function getMonths() { |
|---|
| 1271 | $str = ''; |
|---|
| 1272 | for ($i = 1; $i <= 12; $i++) { |
|---|
| 1273 | if(date('m') == sprintf('%02d', $i)) { |
|---|
| 1274 | $str .= '<option value="'.sprintf('%02d', $i).'" selected>'.sprintf('%02d', $i).' ('.strftime('%B', mktime(0, 0, 0, $i, 1, 2000)).')</option>'; |
|---|
| 1275 | } else { |
|---|
| 1276 | $str .= '<option value="'.sprintf('%02d', $i).'">'.sprintf('%02d', $i).' ('.strftime('%B', mktime(0, 0, 0, $i, 1, 2000)).')</option>'; |
|---|
| 1277 | } |
|---|
| 1278 | } |
|---|
| 1279 | return $str; |
|---|
| 1280 | } |
|---|
| 1281 | public function getYears() { |
|---|
| 1282 | $str = ''; |
|---|
| 1283 | for ($i = date('Y'); $i < date('Y') + 11; $i++) { |
|---|
| 1284 | $str .= '<option value="'.strftime('%Y', mktime(0, 0, 0, 1, 1, $i)).'">'.strftime('%Y', mktime(0, 0, 0, 1, 1, $i)).'</option>'; |
|---|
| 1285 | } |
|---|
| 1286 | return $str; |
|---|
| 1287 | } |
|---|
| 1288 | public function number_format($number, $decimals = 2,$decsep = '', $ths_sep = '') { |
|---|
| 1289 | $parts = explode('.', $number); |
|---|
| 1290 | if(count($parts) > 1) { |
|---|
| 1291 | return $parts[0].'.'.substr($parts[1],0,$decimals); |
|---|
| 1292 | } else { |
|---|
| 1293 | return $number; |
|---|
| 1294 | } |
|---|
| 1295 | } |
|---|
| 1296 | } |
|---|
| 1297 | ?> |
|---|