Changeset 2742
- Timestamp:
- 02/13/10 15:53:05 (2 years ago)
- Files:
-
- trunk/common/lib/Form/Class.FormBO.php (modified) (6 diffs)
- trunk/customer/checkout_process.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/common/lib/Form/Class.FormBO.php
r2735 r2742 378 378 379 379 self::create_subscriptions(); 380 381 380 } 382 381 … … 390 389 $subscription_clause = "id = ".$subscriber; 391 390 $result_sub = $table_subscription->Get_list($FormHandler->DBHandle, $clause); 392 391 393 392 if (is_numeric($subscriber) && is_array($result_sub) && $result_sub[0]['fee'] > 0) { 394 393 … … 407 406 $limite_pay_date = date("Y-m-d",strtotime(" + $billdaybefor_anniversery day")) ; 408 407 409 if ($day_startdate >$lastday_of_next_month){408 if ($day_startdate > $lastday_of_next_month) { 410 409 $next_limite_pay_date = date ("$lastday_of_next_month-m-Y" ,$next_bill_date); 411 410 } else { … … 427 426 $instance_subscription_table -> Add_table ($FormHandler->DBHandle, $value_insert, null, null); 428 427 $reference = generate_invoice_reference(); 428 429 429 //CREATE INVOICE If a new card then just an invoice item in the last invoice 430 430 $field_insert = "date, id_card, title, reference, description, status, paid_status"; … … 435 435 $instance_table = new Table("cc_invoice", $field_insert); 436 436 $id_invoice = $instance_table->Add_table($FormHandler->DBHandle, $value_insert, null, null, "id"); 437 437 438 if (!empty ($id_invoice) && is_numeric($id_invoice)) { 438 439 $description = "Subscription service"; … … 453 454 $mail -> replaceInEmail(Mail::$SUBSCRIPTION_ID,$subscription['id']); 454 455 $mail -> replaceInEmail(Mail::$SUBSCRIPTION_LABEL,$subscription['product_name']); 456 455 457 //insert charge 456 458 $QUERY = "INSERT INTO cc_charge (id_cc_card, amount, chargetype, id_cc_card_subscription, invoiced_status) VALUES ('" . $card_id . "', '" . $subscription['fee'] . "', '3','" . $subscription['card_subscription_id'] . "',1)"; trunk/customer/checkout_process.php
r2737 r2742 39 39 40 40 41 write_log(LOGFILE_EPAYMENT, basename(__FILE__).' line:'.__LINE__."-transactionID=$transactionID"." ----EPAYMENT TRANSACTION START (ID)----"); 42 write_log(LOGFILE_EPAYMENT, basename(__FILE__).' line:'.__LINE__."-transactionKey=$key"." ----EPAYMENT TRANSACTION KEY----"); 43 write_log(LOGFILE_EPAYMENT, basename(__FILE__).' line:'.__LINE__."-POST Var \n".print_r($_POST, true)); 41 write_log(LOGFILE_EPAYMENT, basename(__FILE__).' line:'.__LINE__."EPAYMENT : transactionID=$transactionID - transactionKey=$key \n -POST Var \n".print_r($_POST, true)); 44 42 45 43 if ($sess_id =="") { … … 236 234 } 237 235 238 if(empty($transaction_data[0]['vat']) || !is_numeric($transaction_data[0]['vat'])) $VAT =0; 239 else $VAT = $transaction_data[0]['vat']; 240 241 write_log(LOGFILE_EPAYMENT, basename(__FILE__).' line:'.__LINE__."curr amount $currAmount"); 242 write_log(LOGFILE_EPAYMENT, basename(__FILE__).' line:'.__LINE__."curr $currCurrency ".BASE_CURRENCY); 236 if(empty($transaction_data[0]['vat']) || !is_numeric($transaction_data[0]['vat'])) 237 $VAT =0; 238 else 239 $VAT = $transaction_data[0]['vat']; 240 241 write_log(LOGFILE_EPAYMENT, basename(__FILE__).' line:'.__LINE__."curr amount $currAmount $currCurrency ".BASE_CURRENCY); 243 242 $amount_paid = convert_currency($currencies_list, $currAmount, $currCurrency, BASE_CURRENCY); 244 243 $amount_without_vat = $amount_paid / (1+$VAT/100); … … 277 276 278 277 $QUERY = "SELECT username, credit, lastname, firstname, address, city, state, country, zipcode, phone, email, fax, lastuse, activated, currency, useralias, uipass " . 279 "FROM cc_card " . 280 "WHERE id = '".$transaction_data[0][1]."'"; 281 278 "FROM cc_card WHERE id = '".$transaction_data[0][1]."'"; 282 279 $resmax = $DBHandle_max -> Execute($QUERY); 283 280 if ($resmax) { … … 293 290 294 291 $orderStatus = $payment_modules->get_OrderStatus(); 295 if(empty($item_type)) $transaction_type='balance'; 296 else $transaction_type = $item_type; 292 if(empty($item_type)) 293 $transaction_type='balance'; 294 else 295 $transaction_type = $item_type; 297 296 298 297 $Query = "INSERT INTO cc_payments ( customers_id, customers_name, customers_email_address, item_name, item_id, item_quantity, payment_method, cc_type, cc_owner, " . … … 305 304 306 305 307 // ************************UPDATE THE CREDIT IN THE CARD***********************306 // UPDATE THE CARD CREDIT 308 307 $id = 0; 309 308 if ($customer_info[0] > 0 && $orderStatus == 2) { … … 322 321 if ($id > 0 ) { 323 322 if (strcasecmp("invoice",$item_type)!=0) { 324 325 323 $addcredit = $transaction_data[0][2]; 326 324 $instance_table = new Table("cc_card", "username, id"); … … 335 333 $id_agent = $result_agent[0]['id_agent']; 336 334 $id_agent_insert = "'$id_agent'"; 337 } else{335 } else { 338 336 $id_agent = null; 339 337 $id_agent_insert = "NULL"; … … 376 374 $values = " $id_invoice, $id_payment "; 377 375 $table_payment_invoice->Add_table($DBHandle, $values, $fields); 378 379 376 //END INVOICE 380 //Agent commision 381 // test if this card have a agent382 377 378 // Agent commision 379 // test if this card have a agent 383 380 if (!empty($id_agent)) { 381 384 382 //test if the agent exist and get its commission 385 383 $agent_table = new Table("cc_agent", "commission"); … … 387 385 $result_agent= $agent_table -> Get_list($DBHandle,$agent_clause); 388 386 if(is_array($result_agent) && is_numeric($result_agent[0]['commission']) && $result_agent[0]['commission']>0) { 387 389 388 $field_insert = "id_payment, id_card, amount,description,id_agent,commission_percent,commission_type"; 390 389 $commission = ceil(($amount_without_vat * ($result_agent[0]['commission'])/100)*100)/100; 391 390 $commission_percent = $result_agent[0]['commission']; 391 392 392 $description_commission = gettext("AUTOMATICALY GENERATED COMMISSION!"); 393 393 $description_commission.= "\nID CARD : ".$id; … … 395 395 $description_commission.= "\nPAYMENT AMOUNT: ".$amount_without_vat; 396 396 $description_commission.= "\nCOMMISSION APPLIED: ".$commission_percent; 397 397 398 $value_insert = "'".$id_payment."', '$id', '$commission','$description_commission','$id_agent','$commission_percent','0'"; 398 399 $commission_table = new Table("cc_agent_commission", $field_insert); 399 400 $id_commission = $commission_table -> Add_table ($DBHandle, $value_insert, null, null,"id"); 400 401 write_log(LOGFILE_EPAYMENT, basename(__FILE__).' line:'.__LINE__."-transactionID=$transactionID"." Add_table cc_agent_commission : $field_insert - VALUES $value_insert"); 402 401 403 $table_agent = new Table('cc_agent'); 402 404 $param_update_agent = "com_balance = com_balance + '".$commission."'"; … … 412 414 $invoice_clause = "id = ".$item_id; 413 415 $result_invoice = $invoice_table->Get_list($DBHandle,$invoice_clause); 416 414 417 if (is_array($result_invoice) && sizeof($result_invoice)==1) { 415 416 417 418 $reference =$result_invoice[0][0]; 418 419 … … 422 423 $id_payment = $instance_sub_table -> Add_table ($DBHandle, $value_insert, null, null,"id"); 423 424 write_log(LOGFILE_EPAYMENT, basename(__FILE__).' line:'.__LINE__."-transactionID=$transactionID"." Add_table cc_logpayment : $field_insert - VALUES $value_insert"); 424 //update invoice to paid 425 425 426 //update invoice to paid 426 427 $invoice = new Invoice($item_id); 427 428 $invoice -> addPayment($id_payment); 428 429 $invoice -> changeStatus(1); 429 430 $items = $invoice -> loadItems(); 431 foreach ($items as $item) { 432 if($item -> getExtType() == 'DID' ){ 433 $QUERY = "UPDATE cc_did_use set month_payed = month_payed+1 , reminded = 0 WHERE id_did = '" . $item -> getExtId() . 434 "' AND activated = 1 AND ( releasedate IS NULL OR releasedate < '1984-01-01 00:00:00') "; 435 $instance_table->SQLExec($DBHandle, $QUERY, 0); 436 } 437 if($item -> getExtType() == 'SUBSCR'){ 438 $QUERY = "UPDATE cc_card_subscription SET paid_status = 2 WHERE id=" . $item -> getExtId(); 439 $instance_table->SQLExec($DBHandle, $QUERY, 0); 440 441 } 442 443 } 430 $items = $invoice -> loadItems(); 431 foreach ($items as $item) { 432 if($item -> getExtType() == 'DID' ){ 433 $QUERY = "UPDATE cc_did_use set month_payed = month_payed+1 , reminded = 0 WHERE id_did = '" . $item -> getExtId() . 434 "' AND activated = 1 AND ( releasedate IS NULL OR releasedate < '1984-01-01 00:00:00') "; 435 $instance_table->SQLExec($DBHandle, $QUERY, 0); 436 } 437 if($item -> getExtType() == 'SUBSCR'){ 438 $QUERY = "UPDATE cc_card_subscription SET paid_status = 2 WHERE id=" . $item -> getExtId(); 439 $instance_table->SQLExec($DBHandle, $QUERY, 0); 440 } 441 } 444 442 } 445 446 447 443 } 448 444 } 449 445 } 450 //*************************END UPDATE CREDIT************************************451 446 452 447 $_SESSION["p_amount"] = null;
