Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5141 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I want to run this script: CreateMenu

On this layout: WebOrderSimple2

Here's my PHP code, can someone please tell me exactly what code i need to run to this? Thanks!!!

<?php

//error_reporting(E_ALL);

// ini_set('display_errors', '1');

ob_start();

require_once 'OrderManager.obj.php';

require_once 'vmail.php';

require_once 'ShipGroundDomestic.php';

$OM = OrderManager::getOrderManager();

$fm = $OM->getFilemaker();

if(!($OM->getCustomerID() > 0 ))

{

header("Location:../login.php");

}

if(empty($_SESSION['oldvalue']['SubTotal']))

{

$layoutName = 'web_Step4';

$reid=$OM->getCustomerRecordID();

if(!($reid==NULL|| $reid<=0))

{

$record = $fm->getRecordById($layoutName, $OM->getCustomerRecordID());

if($OM->getCustomerID() != $record->getField('zk_CustomerID',0))

die("error");

}

else

{

die("error");

}

$orderRecords = $record->getRelatedSet("Orders");

}

else

{

if ($_POST) {

foreach ($_POST as $key => $value) {

$_SESSION['oldvalue'][$key] = $value;

}

}

//

$itemstr='';

foreach ($OM->getOrderItems() as $id => $qty){

/* $checkLI = $fm->newFindCommand("webOrderLineItems");

$checkLI->addFindCriterion("InventoryMaster_ID", $id);

$liResult = $checkLI->execute();

$value=0;

if(FileMaker::isError($liResult)){

echo "Error (" . $liRec->getCode() . ") " . $liRec->getMessage();

}else{

$liRec = $liResult->getRecords();

$value=$liRec[0]->getField('InventoryMaster::CurrentBagQtyOnHand', 0);

} *

$li = $fm->createRecord("BaggingNeeds", array("Order_ID" => $OM->getOrderID(),"Inventory_ID" => $id, "Qty" => $qty));

//$OM->checkFMError($li->commit());

$liRec=$li->commit();

if(FileMaker::isError($liRec)){

echo "Error BaggingNeeds(" . $liRec->getCode() . ") " . $liRec->getMessage().'

';

}

$li = $fm->createRecord("webOrderLineItems2", array("Order_ID" => $OM->getOrderID(), "InventoryMaster_ID" => $id, "Qty" => $qty));

//$OM->checkFMError($li->commit());

$liRec=$li->commit();

if(FileMaker::isError($liRec)){

echo "Error webOrderLineItems2 (" . $liRec->getCode() . ") " . $liRec->getMessage().'

';

}

*/

$itemstr .=$id.'|'.$qty.',';

}

$orderFields = array(

"WebSite" => $OM->getWebsite(),

"Meal Program" => $OM->getMealProgram(),

"PayMethod_ID" => $_POST['PaymentMethod_ID'],

"SubTotal" =>$_SESSION['oldvalue']['SubTotal'],

"Tax" => $_SESSION['oldvalue']['Tax'],

"ShipPrice_store" => $_SESSION['oldvalue']['Shipping'],

"Customer ID" => $OM->getCustomerID(),

"SessionMenu" =>trim($itemstr,',')

);

$orderRec = $fm->createRecord('webOrderSimple2', $orderFields);

$OM->checkFMError($orderRec->commit());

$orderid=$orderRec->getRecordID();

$OM->setOrderID($orderid);

$OrderItems = $OM->getOrderItems();

$PickListHash = $OM->getPickListHash();

$totalAmount = str_replace("$","",$_SESSION['oldvalue']['SubTotal']) + str_replace("$","",$_SESSION['oldvalue']['Tax']) + str_replace("$","",$_SESSION['oldvalue']['Shipping']);

$weight=48.0;

$_SESSION['oldvalue']['fedexnum']=$num;

//$num=0;

//$_SESSION['oldvalue']['fedexnum']=0;

/*

if(!empty($itemstr))

{

$li = $fm->createRecord("webOrderSimple", array("SessionMenu" =>trim($itemstr,',')));

//$OM->checkFMError($li->commit());

$liRec=$li->commit();

if(FileMaker::isError($liRec)){

echo "Error webOrderSimple(" . $liRec->getCode() . ") " . $liRec->getMessage().'

';

}

}

///

*/

//print_r($_SESSION['oldvalue']);

if (isset($_POST['Payment_method']) && (array_search($_POST['Payment_method'], $OM->getPayMethods()) !== false )) {

$store=false;

if($_POST['storeck2']=="on" && trim($_POST['BankName'])!="")

{

$store=true;

}

if($_POST['storeck1']=="on" && trim($_POST['NewCreditCardNameOnCard'])!="")

{

$store=true;

}

if($store) {

$payFields = array(

'Customer ID' => $OM->getCustomerID(),

'Card Type' => $OM->fetchPostVar('NewCreditCardType'),

'Method' => $OM->fetchPostVar('Payment_method'),

'CCNumber' => $OM->fetchPostVar('NewCreditCard' ),

'CCExpiration' => $OM->fetchPostVar('NewCreditCardExp' ),

'CCCSV' => $OM->fetchPostVar('NewCreditCard3Digit'),

'CustomerName' => $OM->fetchPostVar('NewCreditCardNameOnCard'),

'Check Account Number' => $OM->fetchPostVar('CheckingAccount'),

'Check Account Routing' => $OM->fetchPostVar('RoutingNumber' ),

'Bank Name' => $OM->fetchPostVar('BankName'));

$cardNumber = $OM->fetchPostVar('NewCreditCard' );

$expires = $OM->fetchPostVar('NewCreditCardExp' );

$payMtdRec = $fm->createRecord("webPaymentMethod", $payFields);

$OM->checkFMError($payMtdRec);

$OM->checkFMError($payMtdRec->commit());

$Pay_Method_ID = $payMtdRec->getRecordID();

}

else

$Pay_Method_ID=-1;

//echo "id is :)$Pay_Method_ID";

//exit;

}elseif (isset($_POST['PaymentMethod_ID'])){ // var not set

$Pay_Method_ID = $_POST['PaymentMethod_ID'];

}//hash for values to be inserted "Filemaker Field Name" => "value"

$isok= "declined";

$layoutName = 'webCustomerBrowse';

$reid=$OM->getCustomerRecordID();

if(!($reid==NULL|| $reid<=0))

{

$record = $fm->getRecordById($layoutName, $OM->getCustomerRecordID());

if($OM->getCustomerID() != $record->getField('zk_CustomerID',0))

die("error");

}

else

{

die("error");

}

$orderRecords = $record->getRelatedSet("Orders");

//Process CC

//start/*

$cust_firstname = htmlentities($_SESSION['oldvalue']['First_Name']);

$cust_lastname = htmlentities($_SESSION['oldvalue']['Last_Name']);

if($Pay_Method_ID>0)

{

$PRecord = $fm->getRecordById('webPaymentMethod', $Pay_Method_ID); // Query for CC details by payment method id

$cardNumber = $PRecord->getField('CCNumber');

$expires = $PRecord->getField('CCExpiration');

$checkingnum= $PRecord->getField('Check Account Number');

$checkrouting= $PRecord->getField('Check Account Routing');

$bankname= $PRecord->getField('Bank Name');

}

else

{

$cardNumber = $_POST['CCNumber'];

$expires = $_POST['CCExpiration'];

$checkingnum= $_POST['Check Account Number'];

$checkrouting= $_POST['Check Account Routing'];

$bankname= $_POST['Bank Name'];

}

$prome=$_POST['promo'];

$ispro=false;

if($prome==$record->getField("promo") && $record->getField("promo")!="" )

{

$ispro=true;

}

if (!($OM->fetchPostVar('BankName') == "admin" || $ispro) )

{

if(!empty($cardNumber))

{

require_once('class_AIM.php');

$testMode = true; //change it to false for productive server

$AuthNet = new Authorize_AIM('99999999999', '56757567567567', $testMode);

$CC = $AuthNet->validateCCNum($cardNumber);

$CheckedNum = $AuthNet->isValid($cardNumber);

if($CC['error'] !== false || $CheckedNum['error'] !== false )

{

if($CC['error'] !== false)

{

$err_code = $CC['error'];

}elseif($CheckedNum['error'] !== false)

{

$err_code = $CheckedNum['error'];

}

echo $err_code;

return;

}

$totalAmount = str_replace("$","",$_SESSION['oldvalue']['SubTotal']) + str_replace("$","",$_SESSION['oldvalue']['Tax']) + str_replace("$","",$_SESSION['oldvalue']['Shipping']);

//echo "CC:$cardNumber";

$AuthNet->putVars($cardNumber, $expires, $totalAmount , '13322', str_replace("$","",$_SESSION['oldvalue']['Tax']), $_SESSION['oldvalue']['Billing_Zip'], $cust_firstname, $cust_lastname, $_SESSION['oldvalue']['Billing_Street_Address']." ".$_SESSION['oldvalue']['Billing_Street_Address2'], $_SESSION['oldvalue']['Billing_City'], 'TX', 'US');

$AuthNet->process();

//echo "result:".$AuthNet->getResultResponseFull();

if( $AuthNet->isApproved()){

$isok="approved";

}

else if ($AuthNet->isDeclined())

{

$df=$fm->newDeleteCommand('webOrderSimple', $OM->getOrderID()); //delete latest order created.

$result = $df->execute();

$OM->setOrderID ("New"); // reset to new Order.

ob_end_clean();

header("location: step3.php?eimsg=1");

exit;

}else if($AuthNet->isError())

{

$df= $fm->newDeleteCommand('webOrderSimple', $OM->getOrderID() ); //delete latest order created.

$result = $df->execute();

$OM->setOrderID ("New"); // reset to new Order.

ob_end_clean();

header("location:step3.php?eimsg=2");

exit;

}

}//End Processing CC

else if(!empty($checkingnum)) //begin processing echeck

{

require_once('Check_AIM.php');

$testMode = true;

$AuthNet = new Checking_AIM('9999999999', '-------------- ', $testMode);

$totalAmount = str_replace("$","",$_SESSION['oldvalue']['SubTotal']) + str_replace("$","",$_SESSION['oldvalue']['Tax']) + str_replace("$","",$_SESSION['oldvalue']['Shipping']);

$AuthNet->putVars($checkingnum, $checkrouting , $bankname , $totalAmount , $cust_firstname, $cust_lastname) ;

$AuthNet->process();

if( $AuthNet->isApproved()){

$isok="approved";

}

else if ($AuthNet->isDeclined())

{

$df=$fm->newDeleteCommand('webOrderSimple', $OM->getOrderID()); //delete latest order created.

$result = $df->execute();

$OM->setOrderID ("New"); // reset to new Order.

ob_end_clean();

header("location: step3.php?eimsg=1");

// echo "deline";

exit;

}else if($AuthNet->isError())

{

$df= $fm->newDeleteCommand('webOrderSimple', $OM->getOrderID() ); //delete latest order created.

$result = $df->execute();

$OM->setOrderID ("New"); // reset to new Order.

// echo "error";

ob_end_clean();

header("location: step3.php?eimsg=2");

exit;

}

else if($AuthNet->isHeld())

{

$df= $fm->newDeleteCommand('webOrderSimple', $OM->getOrderID() ); //delete latest order created.

$result = $df->execute();

$OM->setOrderID ("New"); // reset to new Order.

// echo "hold";

ob_end_clean();

header("location: step3.php?eimsg=3");

exit;

}

}//end processing echecking

}

//end*/

$custFields = array(

'Email' => $_SESSION['oldvalue']['Email'],

'First Name' => $_SESSION['oldvalue']['First_Name'],

'Last Name' => $_SESSION['oldvalue']['Last_Name'],

'Billing Company Name' => $_SESSION['oldvalue']['Billing_Company_Name'],

'Billing Street Address' => $_SESSION['oldvalue']['Billing_Street_Address'],

'Billing Street Address2' => $_SESSION['oldvalue']['Billing_Street_Address2'],

'Billing City' => $_SESSION['oldvalue']['Billing_City'],

'Billing State' => $_SESSION['oldvalue']['Billing_State'],

'Billing Zip' => $_SESSION['oldvalue']['Billing_Zip'],

'Billing Telephone Day' => $_SESSION['oldvalue']['Billing_Telephone_Day'],

'web_TeamLeader' => $_SESSION['oldvalue']['leadername'],

'Shipping Residence' => $_SESSION['oldvalue']['Shipping_Residence'],

'Shipping To Billing Address' => $_SESSION['oldvalue']['Shipping_To_Billing_Address'],

'Shipping First Name' => $_SESSION['oldvalue']['Shipping_First_Name'],

'Shipping Last Name' => $_SESSION['oldvalue']['Shipping_Last_Name'],

'Shipping Company' => $_SESSION['oldvalue']['Shipping_Company'],

'Shipping Street Address' => $_SESSION['oldvalue']['Shipping_Street_Address'],

'Shipping Street Address2' => $_SESSION['oldvalue']['Shipping_Street_Address2'],

'Shipping City' => $_SESSION['oldvalue']['Shipping_City'],

'Shipping State' => $_SESSION['oldvalue']['Shipping_State'],

'Shipping Zip' => $_SESSION['oldvalue']['Shipping_Zip'],

'Team Leader' => $_SESSION['oldvalue']['Team_Leader'],

'Shipping Telephone Day' => $_SESSION['oldvalue']['Shipping_Telephone_Day'],

'Orders::AuthNetResponse' => $isok,

"Referred"=>$_SESSION['oldvalue']['Referred'],

"CellphoneCarrier"=>$_SESSION['oldvalue']['CellphoneCarrier'],

"Orders::Fedex Tracking" => $_SESSION['oldvalue']['fedexnum'],

'Cellphone' => $_SESSION['oldvalue']['Cellphone']

);

foreach ($custFields as $field => $value){

$record->setField($field, $value);

}

$result = $record->commit();

sendordermail();

}

/*

if(($record->getField('SumOfOrdersPerCustomer') == "" || $record->getField('SumOfOrdersPerCustomer') == 0) && strtolower($record->getField('Team Leader', 0)) == "yes")

{

sendordermail($orderRecords[0]->getRecordID(),$num,true);

}

else

sendordermail($orderRecords[0]->getRecordID(),$num,false);

*/

$num=$_SESSION['oldvalue']['fedexnum'];

$alert="";

$OM->clearOrder(); //order has been processed and data written so clear from memory

$show='display:block';

$ret="";

if( substr($record->getField('web_TeamLeader', 0),strlen($record->getField('web_TeamLeader', 0))-4)==1104)

{

$show='display:none';

$ret="&returl=https://www.bestpersonaltrainer.com";

}

?>

Posted

... at what point do you want to run the script... does it have to be executed in any particular context?

Need more info.

This topic is 5141 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.