$moduleAPIName = "Quotes";
$recordOperations = new RecordOperations();
$bodyWrapper = new BodyWrapper();
$records = array();
$recordClass = 'com\zoho\crm\api\record\Record';
$record1 = new $recordClass();
$record1->addKeyValue("Subject", $subj);
if($customer->contact_name){
$contact_name = $this->addSearchContact($customer);
if(!$contact_name["success"]){
return $contact_name;
}
$zohoContactName = new $recordClass();
$zohoContactName->addFieldValue(Contacts::id(), $contact_name["id"]);
$record1->addKeyValue('Contact_Name', $zohoContactName);
}
if($basic_info->description){
$record1->addKeyValue("Description", $basic_info->description);
}
if($basic_info->valid_until){
$record1->addKeyValue("Valid_Till", new \DateTime($basic_info->valid_until));
}
if($basic_info->delivery_date){
$record1->addKeyValue("Required_Delivery_Date", new \DateTime($basic_info->delivery_date));
}
if($pdf_route){
$record1->addKeyValue("Quote_URL", $pdf_route);
}
$record1->addKeyValue("Quote_Wizard_User", Auth::user()->email);
$inventoryLineItemList = array();
foreach($api_items as $item) {
$inventoryLineItem = new InventoryLineItems();
$lineItemProduct = new LineItemProduct();
$lineItemProduct->setId($item["product"]);
$inventoryLineItem->setProduct($lineItemProduct);
$inventoryLineItem->setQuantity($item["quantity"]);
$inventoryLineItem->setListPrice($item["list_price"]);
$discount = $item["discount"];
if($item["discount_type"] == 'percent'){
$discount = $item["discount"] . "%";
}
$inventoryLineItem->setDiscount($discount);
array_push($inventoryLineItemList, $inventoryLineItem);
}
$record1->addKeyValue("Product_Details", $inventoryLineItemList);
array_push($records, $record1);
$bodyWrapper->setData($records);
$trigger = array("approval", "workflow", "blueprint");
$bodyWrapper->setTrigger($trigger);
$headerInstance = new HeaderMap();
$response = $recordOperations->createRecords($moduleAPIName,$bodyWrapper, $headerInstance);