Comments (2)
<?php
// Include classes
include_once('tbs/tbs_class.php');
include_once('tbs/plugins/tbs_plugin_opentbs.php');
// prevent from a PHP configuration problem when using mktime() and date()
if (version_compare(PHP_VERSION,'5.1.0')>=0) {
if (ini_get('date.timezone')=='') {
date_default_timezone_set('UTC');
}
}
// Initialize the TBS instance
$TBS = new clsTinyButStrong; // new instance of TBS
$TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN); // load the OpenTBS plugin
// ------------------------------
// Prepare some data
// ------------------------------
$fields = $_POST;
//echo '<pre>'; print_r($fields); echo '</pre>';
//die();
if (intval($fields['ParkingSpots']) < 1 || intval($fields['ParkingSpots']) > 1) {
$hasOneParking = 0;
} else {
$hasOneParking = 1;
}
$intOrigFee = intval($fields['OriginalFee']);
$intNewFee = intval($fields['NewFee']);
if ($intOrigFee < $intNewFee) {
$hasBiggerNewFee = 1;
$hasBiggerOrigFee = 0;
$hasEqualFees = 0;
} elseif ($intOrigFee > $intNewFee) {
$hasBiggerNewFee = 0;
$hasBiggerOrigFee = 1;
$hasEqualFees = 0;
} else {
$hasBiggerNewFee = 0;
$hasBiggerOrigFee = 0;
$hasEqualFees = 1;
}
if ($fields['PhoneFee'] <= 0) {
$hasNoVoIPPhones = 1;
} else {
$hasNoVoIPPhones = 0;
}
if ($fields['PhoneReceptionFee'] <= 0) {
$hasNoPhoneReceptionService = 1;
} else {
$hasNoPhoneReceptionService = 0;
}
if ($fields['MailForwardFee'] <= 0) {
$hasNoMail = 1;
} else {
$hasNoMail = 0;
}
if (intval($fields['FreeMonth']) === 1) {
$hasFreeMonth = 1;
$hasNoFreeMonth = 0;
} else {
$hasFreeMonth = 0;
$hasNoFreeMonth = 1;
}
$additionalCoins = intval($fields['AdditionalCoins']);
$hasNoAdditionalCoins = $additionalCoins <= 0 ? 1 : 0;
$additionalSecurityDeposit = intval($fields['AdditionalSecurityDeposit']);
$totalSecurityDeposit = intval($fields['TotalSecurityDeposit']);
$hasNoSecurityDeposit = $additionalSecurityDeposit <= 0 || $totalSecurityDeposit <= 0 ? 1 : 0;
$voipLines = $fields['VoIPLines'];
$voipPhones = $fields['VoIPPhones'];
$hasPhoneLineOnly = !empty($voipLines) && empty($voipPhones) ? 1 : 0;
$addSub = $fields['AddSub']; // Amendment Agreement - addition, substitution, or none
$isAdd = $addSub === 'Addition' ? 1 : 0;
$isSub = $addSub === 'Substitution' ? 1 : 0;
if (isset($fields['hasRenewal'])) {
$hasRenewal = 1;
$hasNoRenewal = 0;
//$renewalCoinsIncDec = $fields['RenewalCoinsIncDec'];
//$renewalNewCoins = intval($fields['RenewalNewCoins']);
$renewalTotalCoins = intval($fields['RenewalTotalCoins']);
//$hasRenewalCoins = $renewalNewCoins > 0 && $renewalTotalCoins > 0 ? 1 : 0;
$hasRenewalCoins = $renewalTotalCoins > 0 ? 1 : 0;
$renewalAdditionalSecurityDeposit = intval($fields['RenewalAdditionalSecurityDeposit']);
$renewalTotalSecurityDeposit = intval($fields['RenewalTotalSecurityDeposit']);
$hasRenewalSecurityDeposit = $renewalAdditionalSecurityDeposit > 0 && $renewalTotalSecurityDeposit > 0 ? 1 : 0;
$renewalSuiteNumber = intval($fields['RenewalSuiteNumber']);
$renewalLicenseFee = intval($fields['RenewalLicenseFee']);
} else {
$hasRenewal = 0;
$hasNoRenewal = 1;
//$renewalCoinsIncDec = 0;
//$renewalNewCoins = 0;
$renewalTotalCoins = 0;
$hasRenewalCoins = 0;
$renewalNewSecurityDeposit = 0;
$renewalTotalSecurityDeposit = 0;
$hasRenewalSecurityDeposit = 0;
$RenewalSuiteNumber = 0;
$renewalLicenseFee = 0;
}
if (isset($fields['hasAddSub'])) {
$hasAddSub = 1;
$hasNoAddSub = 0;
//$addSubNewCoins = intval($fields['AddSubNewCoins']);
$addSubTotalCoins = intval($fields['AddSubTotalCoins']);
//$hasAddSubCoins = $addSubNewCoins > 0 && $addSubTotalCoins > 0 ? 1 : 0;
$hasAddSubCoins = $addSubTotalCoins > 0 ? 1 : 0;
$addSubAdditionalSecurityDeposit = intval($fields['AddSubAdditionalSecurityDeposit']);
$addSubTotalSecurityDeposit = intval($fields['AddSubTotalSecurityDeposit']);
$hasAddSubSecurityDeposit = $addSubAdditionalSecurityDeposit > 0 && $addSubTotalSecurityDeposit > 0 ? 1 : 0;
$addSubLicFeeIncDec = $fields['AddSubLicFeeIncDec'];
$addSubNewLicenseFee = $fields['AddSubNewLicenseFee'];
if ($addSubLicFeeIncDec === 'same') {
$fields['AddSubNewLicenseFee'] = "remain unchanged at $" . $addSubNewLicenseFee;
} else {
$fields['AddSubNewLicenseFee'] = $addSubLicFeeIncDec . " to $" . $addSubNewLicenseFee;
}
} else {
$hasAddSub = 0;
$hasNoAddSub = 1;
//$addSubNewCoins = 0;
$addSubTotalCoins = 0;
$hasAddSubCoins = 0;
$addSubNewSecurityDeposit = 0;
$addSubTotalSecurityDeposit = 0;
$hasAddSubSecurityDeposit = 0;
$addSubLicFeeIncDec = 0;
$addSubNewLicenseFee = 0;
}
if (isset($fields['hasParking'])) {
$hasParking = 1;
$hasNoParking = 0;
$hasParkingSpaceLicenseFee = 0;
if (isset($fields['ParkingSpacesIncDec']) && isset($fields['ParkingSpaceLicFeeIncDec'])) {
$hasParkingSpaceLicenseFee = 1;
$parkingSpacesIncDec = $fields['ParkingSpacesIncDec'];
$parkingSpaceLicFeeIncDec = $fields['ParkingSpaceLicFeeIncDec'];
}
$parkingSpaceAdditionalSecurityDeposit = $fields['ParkingSpaceAdditionalSecurityDeposit'];
$parkingSpaceTotalSecurityDeposit = $fields['ParkingSpaceTotalSecurityDeposit'];
$hasParkingSecurityDeposit = $parkingSpaceAdditionalSecurityDeposit > 0 && $parkingSpaceTotalSecurityDeposit > 0 ? 1 : 0;
} else {
$hasParking = 0;
$hasNoParking = 1;
$parkingSpacesIncDec = 0;
$parkingSpaceLicFeeIncDec = 0;
$parkingSpaceAdditionalSecurityDeposit = 0;
$parkingSpaceTotalSecurityDeposit = 0;
$hasParkingSecurityDeposit = 0;
}
$fields['LicenseFee'] = number_format($fields['LicenseFee']);
$fields['TotalMonthlyFee'] = number_format($fields['TotalMonthlyFee']);
$fields['SecurityDeposit'] = number_format($fields['SecurityDeposit']);
if (isset($fields['LicenseeSuiteApt']) && $fields['LicenseeSuiteApt'] !== '') {
//$fields['LicenseeSuiteAptNewLine'] = '^p' . $fields['LicenseeSuiteApt'];
$fields['LicenseeSuiteApt'] = ', ' . $fields['LicenseeSuiteApt'];
}
if (isset($fields['AssigneeSuiteApt']) && $fields['AssigneeSuiteApt'] !== '') {
$fields['AssigneeSuiteApt'] = ', ' . $fields['AssigneeSuiteApt'];
}
// -----------------
// Load the template
// -----------------
$document = $_POST['document_name'];
unset($_POST['document_name']);
$file = $document.'.docx';
$template = 'templates/'.$file;
//echo $template;
$TBS->LoadTemplate($template, OPENTBS_ALREADY_UTF8); // Also merge some [onload] automatic fields (depends of the type of document).
// --------------------------------------------
// Merging and other operations on the template
// --------------------------------------------
// Merge data in the body of the document
//$TBS->MergeBlock('a,b', $fields);
//$TBS->MergeField('fields', $fields);
// Delete comments
$TBS->PlugIn(OPENTBS_DELETE_COMMENTS);
// -----------------
// Output the result
// -----------------
// Define the name of the output file
$save_as = (isset($_POST['save_as']) && (trim($_POST['save_as'])!=='') && ($_SERVER['SERVER_NAME']=='localhost')) ? trim($_POST['save_as']) : '';
$output_file_name = ' ' . $_POST['file_name'] . ".docx";
if (isset($fields['FileNameDate'])) {
$output_file_name = date('n-j-Y', strtotime($fields['FileNameDate'])) . $output_file_name;
} elseif (isset($fields['StartDate'])) {
$output_file_name = date('n-j-Y', strtotime($fields['StartDate'])) . $output_file_name;
} elseif (isset($fields['EffectiveDate'])) {
$output_file_name = date('n-j-Y', strtotime($fields['EffectiveDate'])) . $output_file_name;
}
if ($save_as === '') {
// Output the result as a downloadable file (only streaming, no data saved in the server)
$TBS->Show(OPENTBS_DOWNLOAD, $output_file_name); // Also merges all [onshow] automatic fields.
// Be sure that no more output is done, otherwise the download file is corrupted with extra data.
exit();
} else {
// Output the result as a file on the server.
$TBS->Show(OPENTBS_FILE, $output_file_name); // Also merges all [onshow] automatic fields.
// The script can continue.
exit("File [$output_file_name] has been created.");
}
from opentbs.
The correct place for support is on StackOverflow
For your problem, see :
https://www.tinybutstrong.com/opentbs.php?doc#debug_error
from opentbs.
Related Issues (20)
- Capture output of $tbs->PlugIn(OPENTBS_DEBUG_XML_SHOW)? HOT 2
- How to merge 2 file? HOT 3
- Render hyperlinks in MS-Word and Open Documents HOT 2
- Feature request: changepic from image-data instead of image-file? HOT 2
- Something like "block=tbs:sheet" possible? HOT 3
- The argument locale is ignored when merging a date HOT 3
- ope=changepic does not replace SVG, only the preview-bitmap HOT 4
- Autoload plugin HOT 2
- intl / l10n / number formatting HOT 4
- Timezones supported? Nice would be the support of the DateTimeInterface HOT 1
- text:span elements shadow TBS tags HOT 1
- Adjusted pictures in repeated block cause document to become unreadable HOT 7
- Multi-Lines not managed when reading ODS file HOT 1
- MergeBlock issue with .pptx HOT 1
- Exchange images using MergeBlock() HOT 4
- release for php 8.2 compatibility? HOT 3
- Replacing charts in a multi-slide powerpoint presentation does not work correctly if charts on different slides share a name. HOT 1
- Picture replacement don't work with different open close chars. HOT 1
- changepic of block of images HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opentbs.