I’ve created a “web app” for sales people to use on their iPads at my work by using WordPress + GravityForms and optimizing the css for iPad displays. Using the plugin ‘Gravity Forms PDF Extended’ I was able to output the captured data onto one of our service contract PDFs (I opened the PDF in photoshop and made the background transparent and saved it as a gif), but I can’t seem to use if/elseif/else statements. I had to set all the 0 values as 0’s with a line through them to make them show up, otherwise products with 0’s selected aren’t included in the array.
Here is a picture of what I’m filling in. The red dots are where the variable needs to change depending on the base package. Please take a look at my code and tell me why it’s not working.
Here is the complete code that works fine sans printing **_sensor_quantity_adjusted variables. When I do something like if ($base_package = “Security & Life Safety” {$base_package = “TESTING”;} it will successfully change the name of the base package to TESTING. However, if I do something as simple as if ($base_package = “Security & Life Safety” {$door_sensor_quantity = “TESTING”;} it will throw an error saying:
Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: no name in Entity, line: 110 in /home/username/public_html/newsite/wp-content/plugins/gravity-forms-pdf-extended/render_to_pdf.php on line 70
Unable to stream pdf: headers already sent
Any ideas as to why this might be happening when I try to modify any of the product quantities?
Also, the grand total isn’t being passed either when I uncomment the print_r but that’s a whole separate issue.
<?php
//For backwards compatibility, load wordpress if it hasn't been loaded yet
//Will be used if this file is being called directly
if(!class_exists("RGForms")){
for ( $i = 0; $i < $depth = 10; $i++ ) {
$wp_root_path = str_repeat( '../', $i );
if ( file_exists("{$wp_root_path}wp-load.php" ) ) {
require_once("{$wp_root_path}wp-load.php");
require_once("{$wp_root_path}wp-admin/includes/admin.php");
break;
}
}
//redirect to the login page if user is not authenticated
auth_redirect();
}
if(!GFCommon::current_user_can_any("gravityforms_view_entries") && !defined('GF_FORM_ID') )
die(__("You don't have adequate permission to view entries.", "gravityforms"));
$form_id = (defined('GF_FORM_ID')) ? GF_FORM_ID : absint(rgget("fid"));
$lead_ids = (defined('GF_LEAD_ID')) ? array(GF_LEAD_ID) : explode(',', rgget("lid"));
$page_break = rgget("page_break") ? 'print-page-break' : false;
// sort lead IDs numerically
sort($lead_ids);
if(empty($form_id) || empty($lead_ids))
die(__("Form Id and Lead Id are required parameters.", "gravityforms"));
$form = RGFormsModel::get_form_meta($form_id);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta name="Robots" content="noindex, nofollow" />
<meta http-equiv="Imagetoolbar" content="No" />
<title>
Print Preview :
<?php echo $form["title"] ?> :
<?php echo count($lead_ids) > 1 ? __("Entry # ", "gravityforms") . $lead_ids[0] : 'Bulk Print' ?>
</title>
<link rel='stylesheet' href='<?php echo GFCommon::get_base_url(); ?>/css/print.css' type='text/css' />
</head>
<body>
<div id="print_preview_hdr" style="display:none"></div>
<div id="view-container">
<?php
/* Add image and copy above here to show before the entry details */
require_once(ABSPATH. "wp-content/plugins/gravity-forms-pdf-extended/pdf-entry-detail.php");
foreach($lead_ids as $lead_id){
$lead = RGFormsModel::get_lead($lead_id);
do_action("gform_print_entry_header", $form, $lead);
$form_data = GFEntryDetail::lead_detail_grid_array($form, $lead);
/** Uncomment the following line when figuring out how to access the $form_data array */
//print_r($form_data); exit();
/* contact info fields */
$premise_type = $form_data['field']['Premise Type'];
$todays_date = $form_data['field']['Todays Date'];
$account_name_first = $form_data['field']['Client / Account Name']['first'];
$account_name_last = $form_data['field']['Client / Account Name']['last'];
$premise_phone = $form_data['field']['Premise Phone'];
$premise_address_street = $form_data['field']['Premise Address']['street'];
$premise_address_city = $form_data['field']['Premise Address']['city'];
$premise_address_state = $form_data['field']['Premise Address']['state'];
$premise_address_zip = $form_data['field']['Premise Address']['zip'];
$premise_contact_name = $form_data['field']['Premise Contact Name'];
$premise_contact_phone = $form_data['field']['Premise Contact Phone'];
$premise_contact_email = $form_data['field']['Premise Contact Email'];
$bill_to_name_first = $form_data['field']['Bill to Name']['first'];
$bill_to_name_last = $form_data['field']['Bill to Name']['last'];
$billing_address_street = $form_data['field']['Bill to Address']['street'];
$billing_address_city = $form_data['field']['Bill to Address']['city'];
$billing_address_state = $form_data['field']['Bill to Address']['state'];
$billing_address_zip = $form_data['field']['Bill to Address']['zip'];
$bill_to_contact_name = $form_data['field']['Bill to Contact Name'];
$bill_to_contact_email = $form_data['field']['Bill to Contact Email'];
$bill_to_contact_phone = $form_data['field']['Bill to Contact Phone'];
/* products and quantities */
$base_package = $form_data['products']['0']['name'];
$door_sensor_name = $form_data['products']['1']['name'];
$door_sensor_price = $form_data['products']['1']['price'];
$door_sensor_quantity = $form_data['products']['1']['quantity'];
$window_sensor_name = $form_data['products']['2']['name'];
$window_sensor_price = $form_data['products']['2']['price'];
$window_sensor_quantity = $form_data['products']['2']['quantity'];
$motion_sensor_name = $form_data['products']['3']['name'];
$motion_sensor_price = $form_data['products']['3']['price'];
$motion_sensor_quantity = $form_data['products']['3']['quantity'];
$glassbreak_sensor_name = $form_data['products']['4']['name'];
$glassbreak_sensor_price = $form_data['products']['4']['price'];
$glassbreak_sensor_quantity = $form_data['products']['4']['quantity'];
$smoke_sensor_name = $form_data['products']['5']['name'];
$smoke_sensor_price = $form_data['products']['5']['price'];
$smoke_sensor_quantity = $form_data['products']['5']['quantity'];
$CO2_sensor_name = $form_data['products']['6']['name'];
$CO2_sensor_price = $form_data['products']['6']['price'];
$CO2_sensor_quantity = $form_data['products']['6']['quantity'];
$H20_sensor_name = $form_data['products']['7']['name'];
$H20_sensor_price = $form_data['products']['7']['price'];
$H20_sensor_quantity = $form_data['products']['7']['quantity'];
$remote_touchpanel_name = $form_data['products']['8']['name'];
$remote_touchpanel_price = $form_data['products']['8']['price'];
$remote_touchpanel_quantity = $form_data['products']['8']['quantity'];
$remote_keyfob_name = $form_data['products']['9']['name'];
$remote_keyfob_price = $form_data['products']['9']['price'];
$remote_keyfob_quantity = $form_data['products']['9']['quantity'];
$lamp_module_name = $form_data['products']['10']['name'];
$lamp_module_price = $form_data['products']['10']['price'];
$lamp_module_quantity = $form_data['products']['10']['quantity'];
$appliance_module_name = $form_data['products']['11']['name'];
$appliance_module_price = $form_data['products']['11']['price'];
$appliance_module_quantity = $form_data['products']['11']['quantity'];
$light_switch_name = $form_data['products']['12']['name'];
$light_switch_price = $form_data['products']['12']['price'];
$light_switch_quantity = $form_data['products']['12']['quantity'];
$thermostat_name = $form_data['products']['13']['name'];
$thermostat_price = $form_data['products']['13']['price'];
$thermostat_quantity = $form_data['products']['13']['quantity'];
$door_lock_name = $form_data['products']['14']['name'];
$door_lock_price = $form_data['products']['14']['price'];
$door_lock_quantity = $form_data['products']['14']['quantity'];
$indoor_cam_name = $form_data['products']['15']['name'];
$indoor_cam_price = $form_data['products']['15']['price'];
$indoor_cam_quantity = $form_data['products']['15']['quantity'];
$indoor_cam_nv_name = $form_data['products']['16']['name'];
$indoor_cam_nv_price = $form_data['products']['16']['price'];
$indoor_cam_nv_quantity = $form_data['products']['16']['quantity'];
$indoor_pan_cam_name = $form_data['products']['17']['name'];
$indoor_pan_cam_price = $form_data['products']['17']['price'];
$indoor_pan_cam_quantity = $form_data['products']['17']['quantity'];
$outdoor_cam_name = $form_data['products']['18']['name'];
$outdoor_cam_price = $form_data['products']['18']['price'];
$outdoor_cam_quantity = $form_data['products']['18']['quantity'];
$other_equipment_name = $form_data['field']['Other Equipment:'];
$other_equipment_description = $form_data['field']['Description:'];
$other_equipment_price = $form_data['field']['Price:'];
/* monthly pricing fields */
$video_surveillance_monthly = $form_data['field']['$10/mo for video [Hidden]'];
$video_surveillance_description = $form_data['field']['Video Services Description'];
$monthly_service_fee = $form_data['field']['Monthly Service Fee:'];
/* format the template */
?>
<?php
/*Replace Ø with 0 */
if ($door_sensor_quantity = "Ø")
{$door_sensor_quantity = 0;}
else
{}
?>
<?php
/*Replace Ø with 0 */
if ($window_sensor_quantity = "Ø")
{$window_sensor_quantity = 0;}
else
{}
?>
<?php
/*Replace Ø with 0 */
if ($motion_sensor_quantity = "Ø")
{$motion_sensor_quantity = 0;}
else
{}
?>
<?php
/*Replace Ø with 0 */
if ($glassbreak_sensor_quantity = "Ø")
{$glassbreak_sensor_quantity = 0;}
else
{}
?>
<?php
/*Replace Ø with 0 */
if ($smoke_sensor_quantity = "Ø")
{$smoke_sensor_quantity = 0;}
else
{}
?>
<?php
/*Replace Ø with 0 */
if ($CO2_sensor_quantity = "Ø")
{$CO2_sensor_quantity = 0;}
else
{}
?>
<?php
/*Replace Ø with 0 */
if ($H20_sensor_quantity = "Ø")
{$H20_sensor_quantity = 0;}
else
{}
?>
<?php
/*Replace Ø with 0 */
if ($remote_touchpanel_quantity = "Ø")
{$remote_touchpanel_quantity = 0;}
else
{}
?>
<?php
/*Replace Ø with 0 */
if ($remote_keyfob_quantity = "Ø")
{$remote_keyfob_quantity = 0;}
else
{}
?>
<?php
/*Replace Ø with 0 */
if ($lamp_module_quantity = "Ø")
{$lamp_module_quantity = 0;}
else
{}
?>
<?php
/*Replace Ø with 0 */
if ($appliance_module_quantity = "Ø")
{$appliance_module_quantity = 0;}
else
{}
?>
<?php
/*Replace Ø with 0 */
if ($light_switch_quantity = "Ø")
{$light_switch_quantity = 0;}
else
{}
?>
<?php
/*Replace Ø with 0 */
if ($thermostat_quantity = "Ø")
{$thermostat_quantity = 0;}
else
{}
?>
<?php
/*Replace Ø with 0 */
if ($door_lock_quantity = "Ø")
{$door_lock_quantity = 0;}
else
{}
?>
<?php
/*Replace Ø with 0 */
if ($indoor_cam_quantity = "Ø")
{$indoor_cam_quantity = 0;}
else
{}
?>
<?php
/*Replace Ø with 0 */
if ($indoor_cam_nv_quantity = "Ø")
{$indoor_cam_nv_quantity = 0;}
else
{}
?>
<?php
/*Replace Ø with 0 */
if ($indoor_pan_cam_quantity = "Ø")
{$indoor_pan_cam_quantity = 0;}
else
{}
?>
<?php
/*Replace Ø with 0 */
if ($outdoor_cam_quantity = "Ø")
{$outdoor_cam_quantity = 0;}
else
{}
?>
<div class="body_copy">
<p class="AgreementDate" style="position:absolute;margin-left:525px;margin-top:67px;"><?php echo date('m/d/Y'); ?></p>
<p class="AgreementDateBottom" style="position:absolute;margin-left:550px;margin-top:1205px;"><?php echo date('m/d/Y'); ?></p>
<p class="PremiseType" style="position:absolute;margin-left:265px;margin-top:118px;"><?php echo $premise_type;?></p>
<p class="AccountName" style="position:absolute;margin-left:35px;margin-top:155px;"><?php echo $account_name_first;?> <?php echo $account_name_last;?></p>
<p class="PremiseAddressStreet" style="position:absolute;margin-left:35px;margin-top:188px;"><?php echo $premise_address_street;?> </p>
<p class="PremiseAddressCity" style="position:absolute;margin-left:35px;margin-top:221px;"><?php echo $premise_address_city;?> </p>
<p class="PremiseAddressState" style="position:absolute;margin-left:192px;margin-top:221px;"><?php echo $premise_address_state;?> </p>
<p class="PremiseAddressZIP" style="position:absolute;margin-left:260px;margin-top:221px;"><?php echo $premise_address_zip;?> </p>
<p class="PremisePhone" style="position:absolute;margin-left:35px;margin-top:254px;"><?php echo $premise_phone;?> </p>
<p class="PremiseContactEmail" style="position:absolute;margin-left:162px;margin-top:254px;"><?php echo $premise_contact_email;?> </p>
<p class="PremiseContactCell" style="position:absolute;margin-left:210px;margin-top:287px;"><?php echo $premise_contact_phone;?> </p>
<p class="PremiseContactPerson" style="position:absolute;margin-left:35px;margin-top:287px;"><?php echo $premise_contact_name;?> </p>
<p class="BillToName" style="position:absolute;margin-left:360px;margin-top:155px;"><?php echo $bill_to_name_first;?> <?php echo $bill_to_name_last;?></p>
<p class="BillToStreet" style="position:absolute;margin-left:360px;margin-top:188px;"><?php echo $billing_address_street;?></p>
<p class="BillToCity" style="position:absolute;margin-left:360px;margin-top:221px;"><?php echo $billing_address_city;?></p>
<p class="BillToState" style="position:absolute;margin-left:490px;margin-top:221px;"><?php echo $billing_address_state;?></p>
<p class="BillToZIP" style="position:absolute;margin-left:570px;margin-top:221px;"><?php echo $billing_address_zip;?></p>
<p class="BillToPhone" style="position:absolute;margin-left:360px;margin-top:254px;"><?php echo $bill_to_contact_phone;?></p>
<p class="BillToContactPerson" style="position:absolute;margin-left:360px;margin-top:287px;"><?php echo $bill_to_contact_name;?></p>
<p class="BillToContactEmail" style="position:absolute;margin-left:520px;margin-top:287px;"><?php echo $bill_to_contact_email;?></p>
<p class="BasePackage" style="position:absolute;margin-left:90px;margin-top:329px;"><?php echo $base_package;?> Package</p>
<p class="DoorSensors" style="position:absolute;margin-left:690px;margin-top:346px;font-size:8px;"><?php echo $door_sensor_quantity_adjusted; ?></p>
<p class="WindowSensors" style="position:absolute;margin-left:690px;margin-top:357px;font-size:8px;"><?php echo $window_sensor_quantity; ?></p>
<p class="MotionSensors" style="position:absolute;margin-left:690px;margin-top:370px;font-size:8px;"><?php echo $motion_sensor_quantity_adjusted; ?></p>
<p class="GBSensors" style="position:absolute;margin-left:690px;margin-top:382px;font-size:8px;"><?php echo $glassbreak_sensor_quantity; ?></p>
<p class="SmokeHeatSensors" style="position:absolute;margin-left:690px;margin-top:395px;font-size:8px;"><?php echo $smoke_sensor_quantity_adjusted; ?></p>
<p class="CO2Sensors" style="position:absolute;margin-left:690px;margin-top:407px;font-size:8px;"><?php echo $CO2_sensor_quantity; ?></p>
<p class="WaterSensors" style="position:absolute;margin-left:690px;margin-top:419px;font-size:8px;"><?php echo $H20_sensor_quantity; ?></p>
<p class="RemoteTouchpanel" style="position:absolute;margin-left:690px;margin-top:431px;font-size:8px;"><?php echo $remote_touchpanel_quantity; ?></p>
<p class="RemoteKeyfob" style="position:absolute;margin-left:690px;margin-top:443px;font-size:8px;"><?php echo $remote_keyfob_quantity_adjusted; ?></p>
<p class="LampModules" style="position:absolute;margin-left:690px;margin-top:455px;font-size:8px;"><?php echo $lamp_module_quantity_adjusted; ?></p>
<p class="Appliance Modules" style="position:absolute;margin-left:690px;margin-top:467px;font-size:8px;"><?php echo $appliance_module_quantity; ?></p>
<p class="LightSwitches" style="position:absolute;margin-left:690px;margin-top:479px;font-size:8px;"><?php echo $light_switch_quantity; ?></p>
<p class="Thermostats" style="position:absolute;margin-left:690px;margin-top:491px;font-size:8px;"><?php echo $thermostat_quantity_adjusted; ?></p>
<p class="DoorLocks" style="position:absolute;margin-left:690px;margin-top:507px;font-size:8px;"><?php echo $door_lock_quantity; ?></p>
<p class="IndoorFixedCam" style="position:absolute;margin-left:690px;margin-top:524px;font-size:8px;"><?php echo $indoor_cam_quantity; ?></p>
<p class="IndoorNVCam" style="position:absolute;margin-left:690px;margin-top:537px;font-size:8px;"><?php echo $indoor_cam_nv_quantity; ?></p>
<p class="IndoorPanTilt" style="position:absolute;margin-left:690px;margin-top:549px;font-size:8px;"><?php echo $indoor_pan_cam_quantity; ?></p>
<p class="OutdoorCam" style="position:absolute;margin-left:690px;margin-top:561px;font-size:8px;"><?php echo $outdoor_cam_quantity; ?></p>
<p class="MonthlyVideoCost" style="position:absolute;margin-left:325px;margin-top:730px;"><?php echo $video_surveillance_monthly;?> </p>
<p class="MonthlyFeeTotal" style="position:absolute;margin-left:270px;margin-top:773px;"><?php echo $monthly_service_fee;?> </p>
<p class="VideoServicesDescription" style="position:absolute;margin-left:30px;margin-top:730px;font-size:10px;"><?php echo $video_surveillance_description;?></p>
<img id="background-img" class="bg" src="http://website.com/formbackground.gif" alt="">
</div>
<?php
if(rgget('notes')){
$notes = RGFormsModel::get_lead_notes($lead["id"]);
if(!empty($notes))
{
GFEntryDetail::notes_grid($notes, false);
}
}
// output entry divider/page break
if(array_search($lead_id, $lead_ids) < count($lead_ids) - 1)
echo '<div class="print-hr ' . $page_break . '"></div>';
do_action("gform_print_entry_footer", $form, $lead);
?>
<?php
}
?>
</div>
</body>