通过使用 WordPress + GravityForms 并优化 iPad 显示器的 css,我创建了一个“网络应用程序”供销售人员在他们的 iPad 上使用。使用插件“Gravity Forms PDF Extended”,我能够将捕获的数据输出到我们的服务合同 PDF 之一(我在 Photoshop 中打开 PDF 并使背景透明并将其保存为 gif),但我似乎无法使用 if/elseif/else 语句。我必须将所有 0 值设置为 0,并用一条线穿过它们以使它们显示出来,否则选择了 0 的产品不包含在数组中。
这是我正在填写的图片。红点是变量需要根据基本包更改的地方。请查看我的代码并告诉我为什么它不起作用。这是在没有打印* *_sensor_quantity_adjusted 变量的情况下可以正常工作的完整代码。当我执行 if ($base_package = "Security & Life Safety" {$base_package = "TESTING";} 之类的操作时,它将成功地将基本包的名称更改为 TESTING。但是,如果我做一些像 if ($ base_package = "Security & Life Safety" {$door_sensor_quantity = "TESTING";} 它会抛出一个错误说:
警告:DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef:实体中没有名称,行:/home/username/public_html/newsite/wp-content/plugins/gravity-forms-pdf-extended/render_to_pdf 中的 110。 php on line 70 Unable to stream pdf: headers already sent
当我尝试修改任何产品数量时,关于为什么会发生这种情况的任何想法?
此外,当我取消注释 print_r 时,总计也没有通过,但这是一个完全独立的问题。
<?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>