Sitemap and Filemanager Dialog popup from a form input not working - 5.7.5.9
Permalink
Hi Guys,
I'm currently upgrading a package to 5.7 - all going smooth for the last few days until now. Has been a major mission and would be a shame to give up.
Please could someone let me know if the apparent bugs for the Page Selector and File Picker for forms was ever solved? I saw quite a lot of people having this issue around 2014.
I have a big form in which we need to be able choose a page using the page selector:
<code>
$pageSelect = Core::make('helper/form/page_selector');
$pageSelect->selectPage($f['formName'] . $countFormString, $value);
</code>
And we need to be able to choose files, using the asset library:
<code>
$assetLibrary = Loader::helper('concrete/asset_library');
echo $assetLibrary->image('ccm-b-file', 'fID[new]', t('Select an image'), $fileObject);
</code>
Both dialogs when they open having nothing to display apart from the title (i.e. Sitemap or File Manager). There's nothing to click or choose, its completely grey and blank..
Has anyone got any ideas? Was the bug fixed? Please any help would be so greatly appreciated.
Thanks
I'm currently upgrading a package to 5.7 - all going smooth for the last few days until now. Has been a major mission and would be a shame to give up.
Please could someone let me know if the apparent bugs for the Page Selector and File Picker for forms was ever solved? I saw quite a lot of people having this issue around 2014.
I have a big form in which we need to be able choose a page using the page selector:
<code>
$pageSelect = Core::make('helper/form/page_selector');
$pageSelect->selectPage($f['formName'] . $countFormString, $value);
</code>
And we need to be able to choose files, using the asset library:
<code>
$assetLibrary = Loader::helper('concrete/asset_library');
echo $assetLibrary->image('ccm-b-file', 'fID[new]', t('Select an image'), $fileObject);
</code>
Both dialogs when they open having nothing to display apart from the title (i.e. Sitemap or File Manager). There's nothing to click or choose, its completely grey and blank..
Has anyone got any ideas? Was the bug fixed? Please any help would be so greatly appreciated.
Thanks
Are you using this code in a block your building or a custom page type?
Hi!
Thanks for your reply,
The code which is being used is for a form in a single dashboard page, everything else is working fine apart from the file and page selector. Unfortunately we need these things to work for our whole package to function properly..
[code]
<?php
defined('C5_EXECUTE') or die("Access Denied.");
$bt = Loader::helper('concrete/ui');
// Load the form helper
$fh = Loader::helper('form');
// Load the general helper
$gh = Core::make('tour_manager/functions/general');
// Load editor elements
// Loader::element('editor_config', array('editor_selector' => $gh->getTinyMCEClass(), 'editor_width' => '450px'/*, 'editor_mode' => 'ADVANCED'*/));
// Loader::element('editor_init');
$editor = Core::make('editor');
// echo $editor-> outputBlockEditModeEditor('content', $content);
// Load the custom validation class
$indVal = Core::make('tour_manager/validation/indigo');
// Datetime
$dtt = Core::make('tour_manager/datetime/indigo');
// Set the page 'mode' (add/edit)
if ($tID && $tID != -1) {
$pgMode = 'edit';
} else {
$tID = 0;
$pgMode = 'add';
}
// Declare the controller methods
$cnt = $this->controller;
// generate form elements
function createFormElement($f, $elementCount = null, $required = null, $cnt, $tour, $tID, $overrideVal = null) {
// Load the form helper
$fh = Loader::helper('form');
// Load the general helper
$gh = Core::make('tour_manager/functions/general');
// echo $editor-> outputBlockEditModeEditor('content', $content);
// Image chooser/asset library stuf
$includeAssetLibrary = true;
$assetLibraryPassThru = array(
'type' => 'image'
);
$al = Loader::helper('concrete/asset_library');
// Datetime
$dtt = Core::make('tour_manager/datetime/indigo');
// Setup common form attributes
$attr = array('style' => 'margin-left:10px; margin-bottom:15px;', 'tabindex' => 2);
$attrPrice = array('style' => 'width: 40px; margin-left:10px; margin-bottom:15px;', 'tabindex' => 2);
// Button attributes
$btnAtttr = array('style' => 'position:relative; left:10%; margin-top:15px;');
// Textarea attributes
$taAttr = array('style' => 'margin-left:10px; margin-bottom:15px; width:500px; height:100px; !important', 'tabindex' => 2);
$element = "";
//print_r($overrideVal);
if ($elementCount && strlen($f['formLabel']) > 0) {
$multiple = true;
$countString = ' ('.$elementCount.')';
} else {
$countString = '';
}
if ($elementCount) {
$countFormString = '_' . $elementCount;
} else {
$countFormString = '';
}
if (!$overrideVal) {
$value = $tour[$tID][$f['dbName']];
} else {
$value = $overrideVal[$f['dbName']];
}
$element .= $fh->label($f['formName']. $countFormString, $f['formLabel'] . $countString, array('class' => 'tm-admin-label'));
switch ($f['inputType']) {
default:
case 'text':
if ($f['formName'] == 'tour_accommodation_price' OR $f['formName'] == 'tour_departure_point_price' OR $f['formName'] == 'tour_optional_extra_price' ){
$element .= $fh->text($f['formName'] . $countFormString, $value, $attrPrice);
}
else{
$element .= $fh->text($f['formName'] . $countFormString, $value, $Price);
}
break;
case 'textarea':
// Load editor elements and some config..
/*Loader::element('editor_init');
Loader::element('editor_controls');
$editor = Core::make('editor');
//$element .= $fh->textarea($f['formName'] . $countFormString, $value, $taAttr);*/
$taAttr = array( 'width' => '100',
'style' => 'margin-left: 50px; background-color: #FFF;'
);
$editor = Core::make('editor');
$element .= '<div style = "background-color: #FFFFFF">'.$editor->outputBlockEditModeEditor($f['formName'] . $countFormString, $value, $taAttr).'</div>';
break;
case 'image':
$pictureID = $value;
$bf = empty($pictureID) ? null : File::getByID($pictureID);
$element .= $al->image($value, $f['formName'] . $countFormString, t('Choose Image'), $bf);
break;
case 'date':
//if (!checkdate($value)) {
// $value = date('d/m/Y');
//}
$element .= $dtt->date($f['formName'] . $countFormString, $value, true, $attr);
break;
case 'select':
$options = call_user_func($f['selectFunction'], $cnt);
//print_r($options);
$element .= $fh->select($f['formName'] . $countFormString, $options, $value, $attr);
break;
case 'datetime':
$element .= $dtt->datetime($f['formName'] . $countFormString, $value, false, true, false);
break;
case 'tourDetailSelect':
$pageSelect = Core::make('helper/form/page_selector');
$element .= $pageSelect->selectPage($f['formName'] . $countFormString, $value);
break;
}
if ($required) {
// $element .= "<span class='required'><strong></span>";
}
//$element .= "<br />";
return $element;
}
// Get options for the dropdowns
function getDepPointOptions($cnt) {
$depPointOptions = array();
$depPoints = $cnt->getDeparturePointsList();
for ($i = 0; $i < sizeof($depPoints); $i++) {
$depPointOptions[$depPoints[$i]['dpID']] = $depPoints[$i]['dpName'];
}
return $depPointOptions;
}
// Get options for the dropdowns
function getTourCategoryOptions($cnt) {
$tourCategoryOptions = array();
$tourCategories = $cnt->getTourCategoriesList();
// We need an item for 'no category'
$tourCategoryOptions[0] = "No category";
for ($i = 0; $i < sizeof($tourCategories); $i++) {
$tourCategoryOptions[$tourCategories[$i]['tcID']] = $tourCategories[$i]['tcName'];
}
return $tourCategoryOptions;
}
// Get options for the dropdowns
function getAccTypeOptions($cnt) {
$accTypeOptions = array();
$accTypes = $cnt->getAccommodationTypes();
for ($i = 0; $i < sizeof($accTypes); $i++) {
$accTypeOptions[$accTypes[$i]['atID']] = $accTypes[$i]['atName'];
}
return $accTypeOptions;
}
// Get options for the dropdowns
function getOptionalExtraOptions($cnt) {
$oeOptions = array();
// No extras
$oeOptions[0] = "No extras";
$optExtras = $cnt->getOptionalExtras();
for ($i = 0; $i < sizeof($optExtras); $i++) {
$oeOptions[$optExtras[$i]['oeID']] = $optExtras[$i]['oeName'];
}
return $oeOptions;
}
// Get options for the dropdowns
function getCurrencyOptions($cnt) {
$currencyOptions = array(0 => '£', 1 => '€', 2 => '$');
return $currencyOptions;
}
function getGuaranteeOptions($cnt) {
$GuaranteeOptions = array(0 => 'N/A', 1 => 'Guaranteed Departure');
return $GuaranteeOptions;
}
?>
<div class="ccm-ui">
<div class="row">
<div class="ccm-pane"><?php echo Loader::helper('concrete/dashboard')->getDashboardPaneHeader('Manage Tours', array('This package was created by C.E.Hutton, check out my site:', 'http://www.cehutton.co.uk')); ?>
<div class="ccm-pane-options"><!-- Extra options -->
<a href="<?php echo $this->url('/dashboard/tour_manager/tours/', 'listing'); ?>">Go Back</a>
<?php
//print_r($_REQUEST);
//print_r($debug);
//print_r($errorDebug);
//print_r($pgMode);
?>
</div>
<div class="ccm-pane-body"><?php
// Get required fields
$notNullF = $cnt->getNotNullRequiredFields();
// $tID = 25;
// $pgMode = 'edit';
if ($tID && $pgMode == 'edit') {
echo '<h1 class="admin_cp">Edit a Tour</h1><br />';
// echo $_SESSION['tour_category_count'];
// if (is_numeric($_SESSION['depPointCheck'])){
// echo 'DepPointCount: '.$_SESSION['depPointCheck'];
// }
// else{
// print_r($_SESSION['depPointCheck']);
// echo 'non-numeric';
// }
// print_r($_SESSION['tDepPointsCheck']);
// print_r($_SESSION['tCatsCheck']);
$tour = $cnt->getTours($tID);
$depPoints = $cnt->getTourDeparturePoints($tID);
$accTypes = $gh->getTourAccommodationTypes($tID);
$optExtras = $gh->getTourOptionalExtras($tID);
$tCats = $cnt->getTourCategoriesToTours($tID);
//print_r($depPoints);
//print_r($accTypes);
$tourID = $tID;
$tourCode = $tour[$tID]['tCode'];
$tourName = $tour[$tID]['tName'];
$tourImage = $tour[$tID]['tImage'];
$tourDesc = $tour[$tID]['tDesc'];
$tourDuration = $tour[$tID]['tDuration'];
$tourTotalSeats = $tour[$tID]['tTotalSeats'];
$tourAvailableSeats = $tour[$tID]['tAvailableSeats'];
$tourStart = $tour[$tID]['tStartDate'];
$tourEnd = $tour[$tID]['tEndDate'];
$tourDepart = $tour[$tID]['tDepartureDate'];
$tourReturn = $tour[$tID]['tReturnDate'];
$tourCurrency = $tour[$tID]['tCurrency'];
$tourPrice = $tour[$tID]['tStartingPrice'];
$tourDepPoint = $tour[$tID]['tDeparturePointID'];
$tourDepPointTime = $tour[$tID]['tDeparturePointTime'];
$tourNotes = $tour[$tID]['tNotes'];
$tourAdmissionsInc = $tour[$tID]['tAdmissionsIncluded'];
$tourOptExt = $tour[$tID]['tOptionalExtras'];
$tourAccType = $tour[$tID]['tAccomomdationTypeID'];
$tourAccTypePrice = $tour[$tID]['tAccommodationPrice'];
$tourAccDetails = $tour[$tID]['tAccommodationDetails'];
//echo $tourName;
}
elseif($_SESSION['templateOn'] === 1){
echo '<h1 class="admin_cp">Add a Tour by Template</h1><h2> '.$_SESSION['templatePost'].'</h2>';
//echo '<h1>'.$_SESSION['templateOn'].'</h1>';
foreach($_SESSION['templateNamesArray'] as $key => $value){
if ($_SESSION['templatePost'] === $value){
$templateID = $key;
$tID = $templateID;
// echo $tID;
}
// echo $key.'-'.$value.'</br>';
}
echo '<form method="post" action='.$this->action('process').'>';
echo $fh->select('templateNamesSelect', $_SESSION['templateNamesArray']);
echo $fh->submit('loadTemplate','Load Template');
echo '</form>';
// unset($_SESSION['templateNamesArray']);
//$pgMode = 'add';
$tour = $cnt->getTours($tID);
$depPoints = $cnt->getTourDeparturePoints($tID);
$accTypes = $cnt->getTourAccommodationTypes($tID);
$optExtras = $cnt->getTourOptionalExtras($tID);
if (isset($_SESSION['tCats'])){
$tCats = $_SESSION['tCats'];
unset($_SESSION['tCats']);
}
else{
$tCats = $cnt->getTourCategoriesToTours($tID);
}
//print_r($depPoints);
//print_r($accTypes);
$tourID = $tID;
$tourCode = $tour[$tID]['tCode'];
$tourName = $tour[$tID]['tName'];
$tourImage = $tour[$tID]['tImage'];
$tourDesc = $tour[$tID]['tDesc'];
$tourDuration = $tour[$tID]['tDuration'];
$tourTotalSeats = $tour[$tID]['tTotalSeats'];
$tourAvailableSeats = $tour[$tID]['tAvailableSeats'];
$tourStart = $tour[$tID]['tStartDate'];
$tourEnd = $tour[$tID]['tEndDate'];
$tourDepart = $tour[$tID]['tDepartureDate'];
$tourReturn = $tour[$tID]['tReturnDate'];
$tourCurrency = $tour[$tID]['tCurrency'];
$tourPrice = $tour[$tID]['tStartingPrice'];
$tourDepPoint = $tour[$tID]['tDeparturePointID'];
$tourDepPointTime = $tour[$tID]['tDeparturePointTime'];
$tourNotes = $tour[$tID]['tNotes'];
$tourAdmissionsInc = $tour[$tID]['tAdmissionsIncluded'];
$tourOptExt = $tour[$tID]['tOptionalExtras'];
$tourAccType = $tour[$tID]['tAccomomdationTypeID'];
$tourAccTypePrice = $tour[$tID]['tAccommodationPrice'];
$tourAccDetails = $tour[$tID]['tAccommodationDetails'];
//echo $tID;
// $query = "SELECT * FROM tour_manager_Tours";
// $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
// // if (mysql_num_rows($result) > 0) {
// while($row = mysql_fetch_row($result)) {
//
// if ($row[0] === $templateID){
//
// $tID = $templateId;
// $tourCode = $row[1];
// $tourCategory = $row[2];
// $tourName = $row[3];
// $tourDesc = $row[4];
// $tourImage = $row[5];
// $tourDuration = $row[6];
// $tourTotalSeats = $row[7];
// $tourAvailableSeats = $row[8];
// $tourStart = $row[9];
// $tourEnd = $row[10];
// $tourDepart = $row[11];
// $tourReturn = $row[12];
// $tourCurrency = $row[13];
// $tourPrice = $row[14];
// $tourDepPoint = $row[15];
// $tourDepPointTime = $row[16];
// $tourAccType = $row[17];
// $tourAccTypePrice = $row[18];
// $tourAccDetails = $row[19];
// $tourNotes = $row[20];
// $tourAdmissionsInc = $row[21];
// $tourOptExtras = $row[22];
// // echo "check".'</br>';
// echo $tourName.'</br>';
// // echo $tourPrice.'</br>';
// // echo $pgMode.'</br>';
//
// }
// }
// }
// // $_SESSION['templateOn'] = 0;
// // }
//
// //echo '<p>'.$_SESSION['templatePost'].'</p>';
//
}
elseif(!$tID) {
echo '<h1 class="admin_cp">Add a Tour</h1><br />';
$assetLibrary = Loader::helper('concrete/asset_library');
echo $assetLibrary->image('ccm-b-file', 'fID[new]', t('Select an image'), $fileObject);
$pageSelect = Core::make('helper/form/page_selector');
$pageSelect->selectPage($f['formName'] . $countFormString, $value);
echo '<form method="post" action='.$this->action('process').'>';
echo $fh->select('templateNamesSelect', $_SESSION['templateNamesArray']);
echo $fh->submit('loadTemplate','Load Template');
echo '</form>';
}
//echo '<p>'.$tour[$tID]['tAvailableSeats'].'</p>';
?>
<form method="post" action="<?php echo $this->action('process');?>">
<?php
// Get the field map
$fm = $cnt->getFieldMap();
//print_r($errorArray);
// Get the notnull fileds to ignore
$ignoreNulls = $cnt->getNullsToignore();
// Initailise the $form
$x = 0;
$y = 0;
$z = 0;
$genFunc = Core::make('tour_manager/functions/general');
if ($tID AND $_SESSION['templateOn'] != 1){
$bookings = $genFunc->getBookingsByTour($tID);
$travCount = 0;
foreach ($bookings as $key => $b) {
//$bTravs = $genFunc->getTravellersToBookings($key);
$bTravs = $genFunc->getNumberOfTravellersOnBooking($key);
$travCount += $bTravs;
}
}
else{
$travCount = 'none';
}
$today = date("Y-m-d");
$todayString = strtotime($today);
$departString = strtotime($tour[$tID]['tDepartureDate']);
if ($todayString > $departString){
$releaseCheck = 'true';
}
else{
$releaseCheck = 'false';
}
echo '<table width = "260" height = "50" style = "background-color: #D3EFF6">';
// echo '<tr><td>'.$todayString .'</td></tr>';
// echo '<tr><td>'.$departString.'</td></tr>';
//echo '<th colspan = "3">Admin<th>';
echo '<tr>';
echo '<td><p style = "padding-left: 15px">Number of bookings: <strong>'.$travCount.'</strong></p></td>';
echo '</tr>';
if (is_numeric($travCount) AND $travCount === 0){
echo "<tr><td style = 'padding-left: 15px'>Click <a href='" .$this->url('/dashboard/tour_manager/tours', 'delete', $tID). "'>here</a> to <strong> delete </strong>this tour</td></tr>";
// echo '<tr><td>'.date("l jS \of F Y h:i:s A").'</td></tr>';
}
elseif (is_numeric($travCount) AND $travCount > 0 AND $releaseCheck === 'true'){
echo "<tr><td style = 'padding-left: 15px'>Click <a href='" .$this->action('release_bookings', $tID). "'>here</a> to <strong>release</strong> the bookings from the tour</td></tr>";
// echo '<tr><td>'.date("l jS \of F Y h:i:s A").'</td></tr>';
}
echo '</table>';
$form = '';
$form2 .= '<div style = "clear:both"></div>';
$form .= '<table style= "width:580px; >';
$form .= '<tr>';
$form2.= '<table style= "width:5800px; float:left; display:in-line; background-color: #D3EFF6; margin-right: 15px; padding-left: 10px">';
$form2 .= '<tr>';
foreach($fm as $element) {
//print_r($f);
$keys = array_keys($element);
/*if ($element['notNull']) {
$req = true;
} else {
$req = false;
}*/
if ($element['formName'] != 0 || !in_array($element['dbName'], $ignoreNulls)) {
if($pgMode == 'edit') {
if ($element['inputType'] == 'date' || $element['inputType'] == 'datetime') {
$dateVal = date('d/m/Y H:i:s');
}
}
if (is_array($element) && $indVal->is_multi($element)) {
$multiple = true;
} else {
$multiple = false;
}
//print_r($element['inputType'] . " : ");
if ($multiple) {
$fieldCount = $element[0]['formName'] . '_count';
//echo '[' .$fieldCount. ']';
//echo '[' . ${$fieldCount} .']';
//echo '[' . $_SESSION[$fieldCount] .']';
//print_r($_REQUEST);
$count = ${$fieldCount};
//echo $count;
if (!$count) {
if (isset($_SESSION[$fieldCount])) {
$count = $_SESSION[$fieldCount];
}
else {
$count = 1;
}
}
// Get the group name so we know what to override
$groupName = $element[0]['group'];
// Referenced Tables - override default data if needed
switch ($groupName) {
case 'dep':
$overrideDataArray = $depPoints;
if ($pgMode == 'edit' && $overrideDbFieldCount != true) {
$count = $gh->getRecordCount($tID, 'DeparturePoints_to_Tours', 'tID');
// Save the fieldcount to SESSION for future reference
$gh->setFieldCount('tour_departure_point', $count);
}
elseif ($_SESSION['templateOn'] == '1' AND $_SESSION['depCheck'] != 1) {
$depCheck = 1;
$_SESSION['depCheck'] = $depCheck;
$tIDtemplate = $_SESSION['tIDtemplate'];
$count = $gh->getRecordCount($tID, 'DeparturePoints_to_Tours', 'tID');
// Save the fieldcount to SESSION for future reference
$gh->setFieldCount('tour_departure_point', $count);
// echo $depCountTest;
}
break;
case 'acc':
$overrideDataArray = $accTypes;
if ($pgMode == 'edit' && $overrideDbFieldCount != true) {
$count = $gh->getRecordCount($tID, 'AccommodationTypes_to_Tours', 'tID');
// Save the fieldcount to SESSION for future reference
$gh->setFieldCount('tour_accommodation_type', $count);
}
elseif ($_SESSION['templateOn'] == '1' AND $_SESSION['accCheck'] != 1) {
$accCheck = 1;
$_SESSION['accCheck'] = $accCheck;
$count = $gh->getRecordCount($tID, 'AccommodationTypes_to_Tours', 'tID');
// Save the fieldcount to SESSION for future reference
$gh->setFieldCount('tour_accommodation_type', $count);
}
break;
case 'opt':
$overrideDataArray = $optExtras;
if ($pgMode == 'edit' && $overrideDbFieldCount != true) {
$count = $gh->getRecordCount($tID, 'OptionalExtras_to_Tours', 'tID');
// Save the fieldcount to SESSION for future reference
$gh->setFieldCount('tour_optional_extra', $count);
}
elseif ($_SESSION['templateOn'] == '1' AND $_SESSION['optCheck'] != 1) {
$optCheck = 1;
$_SESSION['optCheck'] = $optCheck;
$tIDtemplate = $_SESSION['tIDtemplate'];
$count = $gh->getRecordCount($tID, 'OptionalExtras_to_Tours', 'tID');
// Save the fieldcount to SESSION for future reference
$gh->setFieldCount('tour_optional_extra', $count);
}
break;
case 'cat':
$overrideDataArray = $tCats;
if ($pgMode == 'edit' && $overrideDbFieldCount != true) {
$count = $gh->getRecordCount($tID, 'TourCategories_to_Tours', 'tID');
// Save the fieldcount to SESSION for future reference
$gh->setFieldCount('tour_category', $count);
}
elseif ($_SESSION['templateOn'] == '1' AND $_SESSION['catCheck'] != 1) {
$catCheck = 1;
$_SESSION['catCheck'] = $catCheck;
$tIDtemplate = $_SESSION['tIDtemplate'];
$count = $gh->getRecordCount($tID, 'TourCategories_to_Tours', 'tID');
// Save the fieldcount to SESSION for future reference
$gh->setFieldCount('tour_category', $count);
}
break;
default:
$overrideDataArray = null;
}
if ($overrideDataArray) {
$override = array();
$oc = 0;
foreach ($overrideDataArray as $key => $val) {
$override[$oc]['key'] = $key;
$override[$oc]['val'] = $val;
$oc++;
}
}
// $count = 1;
// echo '['.$count.']';
if ($count > 1) {
// $formRemove = $fh->submit($element[0]['formName'] .'_remove_submit', 'Remove', array('style' => ''));
$formDisable = $fh->submit($element[0]['formName'] .'_disable_submit', 'Disable', array('style' => ''));
}
else {
//$formRemove = '';
$formDisable = '';
}
// Create as many in the group/array as needed
for ($i = 0; $i < $count; $i++) {
$outputHidden = false;
// echo $element[0]['catID'];
//echo $field['dbName'][0];
// echo '</br></br>';
foreach ($element as $field) {
// print_r( $field);
// echo '</br></br>';
$form .= $fh->hidden($field['formName'] . '_' . ($i+1) . '_id', $override[$i]['key']);
if ($outputHidden == false) {
//print_r($override[$i]);
$form .= $fh->hidden($field['formName'] . '_' . ($i+1) . '_id', $override[$i]['key']);
$outputHidden = true;
}
if ($field['group'] == 'cat'){
if ($i === 0 ){
$form .= '<tr><td colspan = "4" style = "padding-top: 15px"><h2>Tour Categories</h2></td><tr>';
}
$form .= '<td>'.createFormElement($field, ($i+1), $field['notNull'], $cnt, $tour, $tID, $override[$i]['val']).'</td></tr>';
}
elseif ($field['group'] == 'dep'){
$x++;
if ($i === 0 AND $x === 1){
$form .= '<tr><td colspan = "4" style = "padding-top: 15px"><h2>Departure Points</h2></td><tr>';
}
if($x < 4){
$form .= '<td style = "min-width:150px">'.createFormElement($field, ($i+1), $field['notNull'], $cnt, $tour, $tID, $override[$i]['val']).'</td>';
// $form .= '<td>'.($i+1).'</td>';
}
if($x === 3){
if ($override[$i]['val']['dpDisable'] == "0" ){
$form .= '<td width = "50" style = "text-align: center"><a href ="/dashboard/tour_manager/tours/manage/disable/dep/'.$override[$i]['val']['dpID'].'/'.$tID.'/" style = "color: #FFF"><div style = "width: 100px; background-color: #2C9EDD; height: 20px; border-radius:5px; padding-top:5px">DISABLE</div></a></td>';
}
elseif ($override[$i]['val']['dpDisable'] == "1" ){
$form .= '<td width = "50" style = "text-align: center"><a href ="/dashboard/tour_manager/tours/manage/enable/dep/'.$override[$i]['val']['dpID'].'/'.$tID.'/" style = "color: #FFF"><div style = "width: 100px; background-color: #A7072C; height: 20px; border-radius:5px; padding-top:5px">ENABLE</div></a></td>';
}
// print_r($override[$i]['val']);
$form .= '</tr><tr>';
$x = 0;
}
}
elseif ($field['group'] == 'acc'){
$y++;
if ($i === 0 AND $y === 1){
$form .= '<tr><td colspan = "4" style = "padding-top: 15px"><h2>Accommodation Options</h2></td><tr>';
}
if ($y < 2){
$form .= '</tr><td>'.createFormElement($field, ($i+1), $field['notNull'], $cnt, $tour, $tID, $override[$i]['val']).'</td>';
}
elseif($y === 2){
if ($override[$i]['val']['atDisable'] == "0" ){
$form .= '<td width = "100" style = "align-content: center">'.createFormElement($field, ($i+1), $field['notNull'], $cnt, $tour, $tID, $override[$i]['val']).'<td width = "50" style = "text-align: center"><a href ="/dashboard/tour_manager/tours/manage/disable/acc/'.$override[$i]['val']['atID'].'/'.$tID.'/" style = "color: #FFF"><div style = "width: 100px; background-color: #2C9EDD; height: 20px; border-radius:5px; padding-top:5px">DISABLE</div></a></td>';
}
elseif ($override[$i]['val']['atDisable'] == "1" ){
$form .= '<td width = "100" style = "align-content: center">'.createFormElement($field, ($i+1), $field['notNull'], $cnt, $tour, $tID, $override[$i]['val']).'<td width = "50" style = "text-align: center"><a href ="/dashboard/tour_manager/tours/manage/enable/acc/'.$override[$i]['val']['atID'].'/'.$tID.'/" style = "color: #FFF"><div style = "width: 100px; background-color: #A7072C; height: 20px; border-radius:5px; padding-top:5px">ENABLE</div></a></td>';
}
$y = 0;
$form .= '</tr><tr>';
}
}
elseif ($field['group'] == 'opt'){
$z++;
if ($i === 0 AND $z === 1){
$form .= '<tr><td colspan = "4" style = "padding-top: 15px"><h2>Optional Extras</h2></td><tr>';
}
if ($z < 2){
$form .= '<td>'.createFormElement($field, ($i+1), $field['notNull'], $cnt, $tour, $tID, $override[$i]['val']).'</td>';
}
elseif($z === 2){
if ($override[$i]['val']['oeDisable'] == "0" ){
$form .= '<td width = "100" style = "align-content: center">'.createFormElement($field, ($i+1), $field['notNull'], $cnt, $tour, $tID, $override[$i]['val']).'<td width = "50" style = "text-align: center"><a href ="/dashboard/tour_manager/tours/manage/disable/opt/'.$override[$i]['val']['oeID'].'/'.$tID.'/" style = "color: #FFF"><div style = "width: 100px; background-color: #2C9EDD; height: 20px; border-radius:5px; padding-top:5px">DISABLE</div></a></td>';
}
elseif ($override[$i]['val']['oeDisable'] == "1" ){
$form .= '<td width = "100" style = "align-content: center">'.createFormElement($field, ($i+1), $field['notNull'], $cnt, $tour, $tID, $override[$i]['val']).'<td width = "50" style = "text-align: center"><a href ="/dashboard/tour_manager/tours/manage/enable/opt/'.$override[$i]['val']['oeID'].'/'.$tID.'/" style = "color: #FFF"><div style = "width: 100px; background-color: #A7072C; height: 20px; border-radius:5px; padding-top:5px">ENABLE</div></a></td>';
}
$z = 0;
$form .= '</tr><tr>';
}
}
}
}
// Disable add/remove functionality if disableAddRemove == true
if ($element[0]['disableAddRemove'] != true) {
//$form .= $fh->hidden($element[0]['formName'] .'_count', $count);
//$form .= '<p><strong>Add/Remove ' .$element[0]['btnText']. '?</strong></p>';
// $form .= '<strong>';
//$form .= '<a href="'.$this->action('add', $element[0]['formName'], $tour_select, $count).'" class="tm-add-field">Add ' . /*rtrim(strtolower($element[0]['formLabel']), ':')*/ 'Traveller' . '..</a><br />';
$form .= '<tr><td>'.$fh->submit($element[0]['formName'] .'_add_submit', 'Add '.$element[0]['btnText'], array('style' => '')).'</tr>';
if ($count > 1) {
$form .= '<tr><td>'.$fh->submit($element[0]['formName'] .'_remove_submit', 'Remove '.$element[0]['btnText'], array('style' => '')).'</tr>';
}
// $form .= '</strong>';
// $form .= '<br /><br />';
}
// reset count
//if (isset(${$fieldCount}) && stripos($fieldCount, $element[0]['formName']) !== false) {
// $count = 1;
// echo $fieldCount;
//}
} else {
// Just a single element
if ($element['dbName'] =='tCurrency'){
$form .= '<tr><td style = "padding-left: 15px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tGuarantee'){
$form2 .= '<td style = "padding-left: 15px; padding-top:7px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tNotes'){
$form .= '<td style = "padding-left: 15px;" rowspan = "2">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tDesc'){
$form .= '<td style = "padding-left: 15px;" rowspan = "2">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['inputType'] == 'date'){
$form2 .= '<tr><td style = "padding-left: 15px; padding-bottom: 10px">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] == 'tGuideNotes'){
$form2 .= '<td colspan = "2" rowspan = "10" float = "right" style = "padding: 10px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['inputType'] == 'textarea'){
$form2 .= '<tr><td colspan = "4" style = "padding: 10px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['inputType'] == 'tourDetailSelect'){
$form .= '<tr><td colspan = "4" style = "padding: 10px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['inputType'] == 'image'){
$form .= '<tr><td colspan = "4" style = "padding: 10px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tStartingPrice'){
$form2 .= '<tr><td colspan = "1" style = "padding-left: 15px; max-width: 40px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tDiscovery'){
$form2 .= '<td colspan = "1" style = "padding-left: 15px; width: 240px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tStudent'){
$form2 .= '<td colspan = "1" style = "padding-left: 15px; width: 240px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tSlashed'){
$form2 .= '<tr><td colspan = "1" style = "padding-left: 15px; max-width: 40px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tIndigo'){
$form2 .= '<td colspan = "1" style = "padding-left: 15px; max-width: 40px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tAdult'){
$form2 .= '<td colspan = "1" style = "padding-left: 15px; max-width: 40px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tLst'){
$form2 .= '<tr><td><td colspan = "1" style = "padding-left: 15px; max-width: 40px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tSenior'){
$form2 .= '<td colspan = "1" style = "padding-left: 15px; max-width: 40px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tCode'){
$form2 .= '<tr><td colspan = "4" style = "padding-top: 15px"><h2 style = "margin-left: 15px">Tour Details</h2><td><tr>';
$form2 .= '<tr><td style = "padding-left: 15px; width: 40px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tName'){
$form2 .= '<td colspan = "2" style = "padding-left: 15px; width: 400px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tTotalSeats'){
$form2 .= '<tr><td style = "padding-left: 15px; padding-top: 40px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tAvailableSeats'){
$form2 .= '<tr></tr><tr><td style = "padding-left: 15px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tCurrency'){
$form2 .= '<tr><td>'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
else{
$form .= '<tr><td colspan ="1">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID).'</td><td>';
}
$form .= '</tr>';
}
// $form .= "<br />";
}
}
//print_r($cnt->getFieldMap());
// Hidden field if neccessary
if($pgMode == 'edit') {
$form .= $fh->hidden('tID', $tID);
//$form .= $fh->hidden('tourCurrency', '£');
// $form .= "<br />";
}
elseif ($_SESSION['templateOn'] === 1){
$_SESSION['tIDtemplate'] = $tID ;
//echo 'working';
}
$btnAttr2 = array('style' => 'width: 230px; height: 40px; margin-bottom: 8px; margin-left: 15px; margin-top: 120px; background: #25A6E1;
margin-right: 20px;
color:#fff;
font-size:17px;
border-radius:4px;
border:none !important;
box-shadow:none !important;
', 'tabindex' => 2);
// Submit
$form2 .= '<tr><td colspan = "1" >'.$fh->submit('tour_submit', 'Submit', $btnAttr2).'</td><tr>';
// Output
$form .= '</table>';
$form2 .= '</table>';
//echo '<div width = "500px" style = "float:left; display: in-line; padding-right: 50px; padding-top:20px;padding-left:10px">';
echo $form2;
$form .= '<div style = "clear:both"></div>';
//echo '</div>';
//echo '<div width = "300px" style = "float:left; display: in-line; padding-top:20px;">';
echo $form;
echo '</br>';
//echo '</div>';
?>
</form>
<div class="ccm-pane-footer"><!-- Footer --> </div>
</div>
</div>
</div>
[/code]
Many thanks for your opinion!
Thanks for your reply,
The code which is being used is for a form in a single dashboard page, everything else is working fine apart from the file and page selector. Unfortunately we need these things to work for our whole package to function properly..
[code]
<?php
defined('C5_EXECUTE') or die("Access Denied.");
$bt = Loader::helper('concrete/ui');
// Load the form helper
$fh = Loader::helper('form');
// Load the general helper
$gh = Core::make('tour_manager/functions/general');
// Load editor elements
// Loader::element('editor_config', array('editor_selector' => $gh->getTinyMCEClass(), 'editor_width' => '450px'/*, 'editor_mode' => 'ADVANCED'*/));
// Loader::element('editor_init');
$editor = Core::make('editor');
// echo $editor-> outputBlockEditModeEditor('content', $content);
// Load the custom validation class
$indVal = Core::make('tour_manager/validation/indigo');
// Datetime
$dtt = Core::make('tour_manager/datetime/indigo');
// Set the page 'mode' (add/edit)
if ($tID && $tID != -1) {
$pgMode = 'edit';
} else {
$tID = 0;
$pgMode = 'add';
}
// Declare the controller methods
$cnt = $this->controller;
// generate form elements
function createFormElement($f, $elementCount = null, $required = null, $cnt, $tour, $tID, $overrideVal = null) {
// Load the form helper
$fh = Loader::helper('form');
// Load the general helper
$gh = Core::make('tour_manager/functions/general');
// echo $editor-> outputBlockEditModeEditor('content', $content);
// Image chooser/asset library stuf
$includeAssetLibrary = true;
$assetLibraryPassThru = array(
'type' => 'image'
);
$al = Loader::helper('concrete/asset_library');
// Datetime
$dtt = Core::make('tour_manager/datetime/indigo');
// Setup common form attributes
$attr = array('style' => 'margin-left:10px; margin-bottom:15px;', 'tabindex' => 2);
$attrPrice = array('style' => 'width: 40px; margin-left:10px; margin-bottom:15px;', 'tabindex' => 2);
// Button attributes
$btnAtttr = array('style' => 'position:relative; left:10%; margin-top:15px;');
// Textarea attributes
$taAttr = array('style' => 'margin-left:10px; margin-bottom:15px; width:500px; height:100px; !important', 'tabindex' => 2);
$element = "";
//print_r($overrideVal);
if ($elementCount && strlen($f['formLabel']) > 0) {
$multiple = true;
$countString = ' ('.$elementCount.')';
} else {
$countString = '';
}
if ($elementCount) {
$countFormString = '_' . $elementCount;
} else {
$countFormString = '';
}
if (!$overrideVal) {
$value = $tour[$tID][$f['dbName']];
} else {
$value = $overrideVal[$f['dbName']];
}
$element .= $fh->label($f['formName']. $countFormString, $f['formLabel'] . $countString, array('class' => 'tm-admin-label'));
switch ($f['inputType']) {
default:
case 'text':
if ($f['formName'] == 'tour_accommodation_price' OR $f['formName'] == 'tour_departure_point_price' OR $f['formName'] == 'tour_optional_extra_price' ){
$element .= $fh->text($f['formName'] . $countFormString, $value, $attrPrice);
}
else{
$element .= $fh->text($f['formName'] . $countFormString, $value, $Price);
}
break;
case 'textarea':
// Load editor elements and some config..
/*Loader::element('editor_init');
Loader::element('editor_controls');
$editor = Core::make('editor');
//$element .= $fh->textarea($f['formName'] . $countFormString, $value, $taAttr);*/
$taAttr = array( 'width' => '100',
'style' => 'margin-left: 50px; background-color: #FFF;'
);
$editor = Core::make('editor');
$element .= '<div style = "background-color: #FFFFFF">'.$editor->outputBlockEditModeEditor($f['formName'] . $countFormString, $value, $taAttr).'</div>';
break;
case 'image':
$pictureID = $value;
$bf = empty($pictureID) ? null : File::getByID($pictureID);
$element .= $al->image($value, $f['formName'] . $countFormString, t('Choose Image'), $bf);
break;
case 'date':
//if (!checkdate($value)) {
// $value = date('d/m/Y');
//}
$element .= $dtt->date($f['formName'] . $countFormString, $value, true, $attr);
break;
case 'select':
$options = call_user_func($f['selectFunction'], $cnt);
//print_r($options);
$element .= $fh->select($f['formName'] . $countFormString, $options, $value, $attr);
break;
case 'datetime':
$element .= $dtt->datetime($f['formName'] . $countFormString, $value, false, true, false);
break;
case 'tourDetailSelect':
$pageSelect = Core::make('helper/form/page_selector');
$element .= $pageSelect->selectPage($f['formName'] . $countFormString, $value);
break;
}
if ($required) {
// $element .= "<span class='required'><strong></span>";
}
//$element .= "<br />";
return $element;
}
// Get options for the dropdowns
function getDepPointOptions($cnt) {
$depPointOptions = array();
$depPoints = $cnt->getDeparturePointsList();
for ($i = 0; $i < sizeof($depPoints); $i++) {
$depPointOptions[$depPoints[$i]['dpID']] = $depPoints[$i]['dpName'];
}
return $depPointOptions;
}
// Get options for the dropdowns
function getTourCategoryOptions($cnt) {
$tourCategoryOptions = array();
$tourCategories = $cnt->getTourCategoriesList();
// We need an item for 'no category'
$tourCategoryOptions[0] = "No category";
for ($i = 0; $i < sizeof($tourCategories); $i++) {
$tourCategoryOptions[$tourCategories[$i]['tcID']] = $tourCategories[$i]['tcName'];
}
return $tourCategoryOptions;
}
// Get options for the dropdowns
function getAccTypeOptions($cnt) {
$accTypeOptions = array();
$accTypes = $cnt->getAccommodationTypes();
for ($i = 0; $i < sizeof($accTypes); $i++) {
$accTypeOptions[$accTypes[$i]['atID']] = $accTypes[$i]['atName'];
}
return $accTypeOptions;
}
// Get options for the dropdowns
function getOptionalExtraOptions($cnt) {
$oeOptions = array();
// No extras
$oeOptions[0] = "No extras";
$optExtras = $cnt->getOptionalExtras();
for ($i = 0; $i < sizeof($optExtras); $i++) {
$oeOptions[$optExtras[$i]['oeID']] = $optExtras[$i]['oeName'];
}
return $oeOptions;
}
// Get options for the dropdowns
function getCurrencyOptions($cnt) {
$currencyOptions = array(0 => '£', 1 => '€', 2 => '$');
return $currencyOptions;
}
function getGuaranteeOptions($cnt) {
$GuaranteeOptions = array(0 => 'N/A', 1 => 'Guaranteed Departure');
return $GuaranteeOptions;
}
?>
<div class="ccm-ui">
<div class="row">
<div class="ccm-pane"><?php echo Loader::helper('concrete/dashboard')->getDashboardPaneHeader('Manage Tours', array('This package was created by C.E.Hutton, check out my site:', 'http://www.cehutton.co.uk')); ?>
<div class="ccm-pane-options"><!-- Extra options -->
<a href="<?php echo $this->url('/dashboard/tour_manager/tours/', 'listing'); ?>">Go Back</a>
<?php
//print_r($_REQUEST);
//print_r($debug);
//print_r($errorDebug);
//print_r($pgMode);
?>
</div>
<div class="ccm-pane-body"><?php
// Get required fields
$notNullF = $cnt->getNotNullRequiredFields();
// $tID = 25;
// $pgMode = 'edit';
if ($tID && $pgMode == 'edit') {
echo '<h1 class="admin_cp">Edit a Tour</h1><br />';
// echo $_SESSION['tour_category_count'];
// if (is_numeric($_SESSION['depPointCheck'])){
// echo 'DepPointCount: '.$_SESSION['depPointCheck'];
// }
// else{
// print_r($_SESSION['depPointCheck']);
// echo 'non-numeric';
// }
// print_r($_SESSION['tDepPointsCheck']);
// print_r($_SESSION['tCatsCheck']);
$tour = $cnt->getTours($tID);
$depPoints = $cnt->getTourDeparturePoints($tID);
$accTypes = $gh->getTourAccommodationTypes($tID);
$optExtras = $gh->getTourOptionalExtras($tID);
$tCats = $cnt->getTourCategoriesToTours($tID);
//print_r($depPoints);
//print_r($accTypes);
$tourID = $tID;
$tourCode = $tour[$tID]['tCode'];
$tourName = $tour[$tID]['tName'];
$tourImage = $tour[$tID]['tImage'];
$tourDesc = $tour[$tID]['tDesc'];
$tourDuration = $tour[$tID]['tDuration'];
$tourTotalSeats = $tour[$tID]['tTotalSeats'];
$tourAvailableSeats = $tour[$tID]['tAvailableSeats'];
$tourStart = $tour[$tID]['tStartDate'];
$tourEnd = $tour[$tID]['tEndDate'];
$tourDepart = $tour[$tID]['tDepartureDate'];
$tourReturn = $tour[$tID]['tReturnDate'];
$tourCurrency = $tour[$tID]['tCurrency'];
$tourPrice = $tour[$tID]['tStartingPrice'];
$tourDepPoint = $tour[$tID]['tDeparturePointID'];
$tourDepPointTime = $tour[$tID]['tDeparturePointTime'];
$tourNotes = $tour[$tID]['tNotes'];
$tourAdmissionsInc = $tour[$tID]['tAdmissionsIncluded'];
$tourOptExt = $tour[$tID]['tOptionalExtras'];
$tourAccType = $tour[$tID]['tAccomomdationTypeID'];
$tourAccTypePrice = $tour[$tID]['tAccommodationPrice'];
$tourAccDetails = $tour[$tID]['tAccommodationDetails'];
//echo $tourName;
}
elseif($_SESSION['templateOn'] === 1){
echo '<h1 class="admin_cp">Add a Tour by Template</h1><h2> '.$_SESSION['templatePost'].'</h2>';
//echo '<h1>'.$_SESSION['templateOn'].'</h1>';
foreach($_SESSION['templateNamesArray'] as $key => $value){
if ($_SESSION['templatePost'] === $value){
$templateID = $key;
$tID = $templateID;
// echo $tID;
}
// echo $key.'-'.$value.'</br>';
}
echo '<form method="post" action='.$this->action('process').'>';
echo $fh->select('templateNamesSelect', $_SESSION['templateNamesArray']);
echo $fh->submit('loadTemplate','Load Template');
echo '</form>';
// unset($_SESSION['templateNamesArray']);
//$pgMode = 'add';
$tour = $cnt->getTours($tID);
$depPoints = $cnt->getTourDeparturePoints($tID);
$accTypes = $cnt->getTourAccommodationTypes($tID);
$optExtras = $cnt->getTourOptionalExtras($tID);
if (isset($_SESSION['tCats'])){
$tCats = $_SESSION['tCats'];
unset($_SESSION['tCats']);
}
else{
$tCats = $cnt->getTourCategoriesToTours($tID);
}
//print_r($depPoints);
//print_r($accTypes);
$tourID = $tID;
$tourCode = $tour[$tID]['tCode'];
$tourName = $tour[$tID]['tName'];
$tourImage = $tour[$tID]['tImage'];
$tourDesc = $tour[$tID]['tDesc'];
$tourDuration = $tour[$tID]['tDuration'];
$tourTotalSeats = $tour[$tID]['tTotalSeats'];
$tourAvailableSeats = $tour[$tID]['tAvailableSeats'];
$tourStart = $tour[$tID]['tStartDate'];
$tourEnd = $tour[$tID]['tEndDate'];
$tourDepart = $tour[$tID]['tDepartureDate'];
$tourReturn = $tour[$tID]['tReturnDate'];
$tourCurrency = $tour[$tID]['tCurrency'];
$tourPrice = $tour[$tID]['tStartingPrice'];
$tourDepPoint = $tour[$tID]['tDeparturePointID'];
$tourDepPointTime = $tour[$tID]['tDeparturePointTime'];
$tourNotes = $tour[$tID]['tNotes'];
$tourAdmissionsInc = $tour[$tID]['tAdmissionsIncluded'];
$tourOptExt = $tour[$tID]['tOptionalExtras'];
$tourAccType = $tour[$tID]['tAccomomdationTypeID'];
$tourAccTypePrice = $tour[$tID]['tAccommodationPrice'];
$tourAccDetails = $tour[$tID]['tAccommodationDetails'];
//echo $tID;
// $query = "SELECT * FROM tour_manager_Tours";
// $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
// // if (mysql_num_rows($result) > 0) {
// while($row = mysql_fetch_row($result)) {
//
// if ($row[0] === $templateID){
//
// $tID = $templateId;
// $tourCode = $row[1];
// $tourCategory = $row[2];
// $tourName = $row[3];
// $tourDesc = $row[4];
// $tourImage = $row[5];
// $tourDuration = $row[6];
// $tourTotalSeats = $row[7];
// $tourAvailableSeats = $row[8];
// $tourStart = $row[9];
// $tourEnd = $row[10];
// $tourDepart = $row[11];
// $tourReturn = $row[12];
// $tourCurrency = $row[13];
// $tourPrice = $row[14];
// $tourDepPoint = $row[15];
// $tourDepPointTime = $row[16];
// $tourAccType = $row[17];
// $tourAccTypePrice = $row[18];
// $tourAccDetails = $row[19];
// $tourNotes = $row[20];
// $tourAdmissionsInc = $row[21];
// $tourOptExtras = $row[22];
// // echo "check".'</br>';
// echo $tourName.'</br>';
// // echo $tourPrice.'</br>';
// // echo $pgMode.'</br>';
//
// }
// }
// }
// // $_SESSION['templateOn'] = 0;
// // }
//
// //echo '<p>'.$_SESSION['templatePost'].'</p>';
//
}
elseif(!$tID) {
echo '<h1 class="admin_cp">Add a Tour</h1><br />';
$assetLibrary = Loader::helper('concrete/asset_library');
echo $assetLibrary->image('ccm-b-file', 'fID[new]', t('Select an image'), $fileObject);
$pageSelect = Core::make('helper/form/page_selector');
$pageSelect->selectPage($f['formName'] . $countFormString, $value);
echo '<form method="post" action='.$this->action('process').'>';
echo $fh->select('templateNamesSelect', $_SESSION['templateNamesArray']);
echo $fh->submit('loadTemplate','Load Template');
echo '</form>';
}
//echo '<p>'.$tour[$tID]['tAvailableSeats'].'</p>';
?>
<form method="post" action="<?php echo $this->action('process');?>">
<?php
// Get the field map
$fm = $cnt->getFieldMap();
//print_r($errorArray);
// Get the notnull fileds to ignore
$ignoreNulls = $cnt->getNullsToignore();
// Initailise the $form
$x = 0;
$y = 0;
$z = 0;
$genFunc = Core::make('tour_manager/functions/general');
if ($tID AND $_SESSION['templateOn'] != 1){
$bookings = $genFunc->getBookingsByTour($tID);
$travCount = 0;
foreach ($bookings as $key => $b) {
//$bTravs = $genFunc->getTravellersToBookings($key);
$bTravs = $genFunc->getNumberOfTravellersOnBooking($key);
$travCount += $bTravs;
}
}
else{
$travCount = 'none';
}
$today = date("Y-m-d");
$todayString = strtotime($today);
$departString = strtotime($tour[$tID]['tDepartureDate']);
if ($todayString > $departString){
$releaseCheck = 'true';
}
else{
$releaseCheck = 'false';
}
echo '<table width = "260" height = "50" style = "background-color: #D3EFF6">';
// echo '<tr><td>'.$todayString .'</td></tr>';
// echo '<tr><td>'.$departString.'</td></tr>';
//echo '<th colspan = "3">Admin<th>';
echo '<tr>';
echo '<td><p style = "padding-left: 15px">Number of bookings: <strong>'.$travCount.'</strong></p></td>';
echo '</tr>';
if (is_numeric($travCount) AND $travCount === 0){
echo "<tr><td style = 'padding-left: 15px'>Click <a href='" .$this->url('/dashboard/tour_manager/tours', 'delete', $tID). "'>here</a> to <strong> delete </strong>this tour</td></tr>";
// echo '<tr><td>'.date("l jS \of F Y h:i:s A").'</td></tr>';
}
elseif (is_numeric($travCount) AND $travCount > 0 AND $releaseCheck === 'true'){
echo "<tr><td style = 'padding-left: 15px'>Click <a href='" .$this->action('release_bookings', $tID). "'>here</a> to <strong>release</strong> the bookings from the tour</td></tr>";
// echo '<tr><td>'.date("l jS \of F Y h:i:s A").'</td></tr>';
}
echo '</table>';
$form = '';
$form2 .= '<div style = "clear:both"></div>';
$form .= '<table style= "width:580px; >';
$form .= '<tr>';
$form2.= '<table style= "width:5800px; float:left; display:in-line; background-color: #D3EFF6; margin-right: 15px; padding-left: 10px">';
$form2 .= '<tr>';
foreach($fm as $element) {
//print_r($f);
$keys = array_keys($element);
/*if ($element['notNull']) {
$req = true;
} else {
$req = false;
}*/
if ($element['formName'] != 0 || !in_array($element['dbName'], $ignoreNulls)) {
if($pgMode == 'edit') {
if ($element['inputType'] == 'date' || $element['inputType'] == 'datetime') {
$dateVal = date('d/m/Y H:i:s');
}
}
if (is_array($element) && $indVal->is_multi($element)) {
$multiple = true;
} else {
$multiple = false;
}
//print_r($element['inputType'] . " : ");
if ($multiple) {
$fieldCount = $element[0]['formName'] . '_count';
//echo '[' .$fieldCount. ']';
//echo '[' . ${$fieldCount} .']';
//echo '[' . $_SESSION[$fieldCount] .']';
//print_r($_REQUEST);
$count = ${$fieldCount};
//echo $count;
if (!$count) {
if (isset($_SESSION[$fieldCount])) {
$count = $_SESSION[$fieldCount];
}
else {
$count = 1;
}
}
// Get the group name so we know what to override
$groupName = $element[0]['group'];
// Referenced Tables - override default data if needed
switch ($groupName) {
case 'dep':
$overrideDataArray = $depPoints;
if ($pgMode == 'edit' && $overrideDbFieldCount != true) {
$count = $gh->getRecordCount($tID, 'DeparturePoints_to_Tours', 'tID');
// Save the fieldcount to SESSION for future reference
$gh->setFieldCount('tour_departure_point', $count);
}
elseif ($_SESSION['templateOn'] == '1' AND $_SESSION['depCheck'] != 1) {
$depCheck = 1;
$_SESSION['depCheck'] = $depCheck;
$tIDtemplate = $_SESSION['tIDtemplate'];
$count = $gh->getRecordCount($tID, 'DeparturePoints_to_Tours', 'tID');
// Save the fieldcount to SESSION for future reference
$gh->setFieldCount('tour_departure_point', $count);
// echo $depCountTest;
}
break;
case 'acc':
$overrideDataArray = $accTypes;
if ($pgMode == 'edit' && $overrideDbFieldCount != true) {
$count = $gh->getRecordCount($tID, 'AccommodationTypes_to_Tours', 'tID');
// Save the fieldcount to SESSION for future reference
$gh->setFieldCount('tour_accommodation_type', $count);
}
elseif ($_SESSION['templateOn'] == '1' AND $_SESSION['accCheck'] != 1) {
$accCheck = 1;
$_SESSION['accCheck'] = $accCheck;
$count = $gh->getRecordCount($tID, 'AccommodationTypes_to_Tours', 'tID');
// Save the fieldcount to SESSION for future reference
$gh->setFieldCount('tour_accommodation_type', $count);
}
break;
case 'opt':
$overrideDataArray = $optExtras;
if ($pgMode == 'edit' && $overrideDbFieldCount != true) {
$count = $gh->getRecordCount($tID, 'OptionalExtras_to_Tours', 'tID');
// Save the fieldcount to SESSION for future reference
$gh->setFieldCount('tour_optional_extra', $count);
}
elseif ($_SESSION['templateOn'] == '1' AND $_SESSION['optCheck'] != 1) {
$optCheck = 1;
$_SESSION['optCheck'] = $optCheck;
$tIDtemplate = $_SESSION['tIDtemplate'];
$count = $gh->getRecordCount($tID, 'OptionalExtras_to_Tours', 'tID');
// Save the fieldcount to SESSION for future reference
$gh->setFieldCount('tour_optional_extra', $count);
}
break;
case 'cat':
$overrideDataArray = $tCats;
if ($pgMode == 'edit' && $overrideDbFieldCount != true) {
$count = $gh->getRecordCount($tID, 'TourCategories_to_Tours', 'tID');
// Save the fieldcount to SESSION for future reference
$gh->setFieldCount('tour_category', $count);
}
elseif ($_SESSION['templateOn'] == '1' AND $_SESSION['catCheck'] != 1) {
$catCheck = 1;
$_SESSION['catCheck'] = $catCheck;
$tIDtemplate = $_SESSION['tIDtemplate'];
$count = $gh->getRecordCount($tID, 'TourCategories_to_Tours', 'tID');
// Save the fieldcount to SESSION for future reference
$gh->setFieldCount('tour_category', $count);
}
break;
default:
$overrideDataArray = null;
}
if ($overrideDataArray) {
$override = array();
$oc = 0;
foreach ($overrideDataArray as $key => $val) {
$override[$oc]['key'] = $key;
$override[$oc]['val'] = $val;
$oc++;
}
}
// $count = 1;
// echo '['.$count.']';
if ($count > 1) {
// $formRemove = $fh->submit($element[0]['formName'] .'_remove_submit', 'Remove', array('style' => ''));
$formDisable = $fh->submit($element[0]['formName'] .'_disable_submit', 'Disable', array('style' => ''));
}
else {
//$formRemove = '';
$formDisable = '';
}
// Create as many in the group/array as needed
for ($i = 0; $i < $count; $i++) {
$outputHidden = false;
// echo $element[0]['catID'];
//echo $field['dbName'][0];
// echo '</br></br>';
foreach ($element as $field) {
// print_r( $field);
// echo '</br></br>';
$form .= $fh->hidden($field['formName'] . '_' . ($i+1) . '_id', $override[$i]['key']);
if ($outputHidden == false) {
//print_r($override[$i]);
$form .= $fh->hidden($field['formName'] . '_' . ($i+1) . '_id', $override[$i]['key']);
$outputHidden = true;
}
if ($field['group'] == 'cat'){
if ($i === 0 ){
$form .= '<tr><td colspan = "4" style = "padding-top: 15px"><h2>Tour Categories</h2></td><tr>';
}
$form .= '<td>'.createFormElement($field, ($i+1), $field['notNull'], $cnt, $tour, $tID, $override[$i]['val']).'</td></tr>';
}
elseif ($field['group'] == 'dep'){
$x++;
if ($i === 0 AND $x === 1){
$form .= '<tr><td colspan = "4" style = "padding-top: 15px"><h2>Departure Points</h2></td><tr>';
}
if($x < 4){
$form .= '<td style = "min-width:150px">'.createFormElement($field, ($i+1), $field['notNull'], $cnt, $tour, $tID, $override[$i]['val']).'</td>';
// $form .= '<td>'.($i+1).'</td>';
}
if($x === 3){
if ($override[$i]['val']['dpDisable'] == "0" ){
$form .= '<td width = "50" style = "text-align: center"><a href ="/dashboard/tour_manager/tours/manage/disable/dep/'.$override[$i]['val']['dpID'].'/'.$tID.'/" style = "color: #FFF"><div style = "width: 100px; background-color: #2C9EDD; height: 20px; border-radius:5px; padding-top:5px">DISABLE</div></a></td>';
}
elseif ($override[$i]['val']['dpDisable'] == "1" ){
$form .= '<td width = "50" style = "text-align: center"><a href ="/dashboard/tour_manager/tours/manage/enable/dep/'.$override[$i]['val']['dpID'].'/'.$tID.'/" style = "color: #FFF"><div style = "width: 100px; background-color: #A7072C; height: 20px; border-radius:5px; padding-top:5px">ENABLE</div></a></td>';
}
// print_r($override[$i]['val']);
$form .= '</tr><tr>';
$x = 0;
}
}
elseif ($field['group'] == 'acc'){
$y++;
if ($i === 0 AND $y === 1){
$form .= '<tr><td colspan = "4" style = "padding-top: 15px"><h2>Accommodation Options</h2></td><tr>';
}
if ($y < 2){
$form .= '</tr><td>'.createFormElement($field, ($i+1), $field['notNull'], $cnt, $tour, $tID, $override[$i]['val']).'</td>';
}
elseif($y === 2){
if ($override[$i]['val']['atDisable'] == "0" ){
$form .= '<td width = "100" style = "align-content: center">'.createFormElement($field, ($i+1), $field['notNull'], $cnt, $tour, $tID, $override[$i]['val']).'<td width = "50" style = "text-align: center"><a href ="/dashboard/tour_manager/tours/manage/disable/acc/'.$override[$i]['val']['atID'].'/'.$tID.'/" style = "color: #FFF"><div style = "width: 100px; background-color: #2C9EDD; height: 20px; border-radius:5px; padding-top:5px">DISABLE</div></a></td>';
}
elseif ($override[$i]['val']['atDisable'] == "1" ){
$form .= '<td width = "100" style = "align-content: center">'.createFormElement($field, ($i+1), $field['notNull'], $cnt, $tour, $tID, $override[$i]['val']).'<td width = "50" style = "text-align: center"><a href ="/dashboard/tour_manager/tours/manage/enable/acc/'.$override[$i]['val']['atID'].'/'.$tID.'/" style = "color: #FFF"><div style = "width: 100px; background-color: #A7072C; height: 20px; border-radius:5px; padding-top:5px">ENABLE</div></a></td>';
}
$y = 0;
$form .= '</tr><tr>';
}
}
elseif ($field['group'] == 'opt'){
$z++;
if ($i === 0 AND $z === 1){
$form .= '<tr><td colspan = "4" style = "padding-top: 15px"><h2>Optional Extras</h2></td><tr>';
}
if ($z < 2){
$form .= '<td>'.createFormElement($field, ($i+1), $field['notNull'], $cnt, $tour, $tID, $override[$i]['val']).'</td>';
}
elseif($z === 2){
if ($override[$i]['val']['oeDisable'] == "0" ){
$form .= '<td width = "100" style = "align-content: center">'.createFormElement($field, ($i+1), $field['notNull'], $cnt, $tour, $tID, $override[$i]['val']).'<td width = "50" style = "text-align: center"><a href ="/dashboard/tour_manager/tours/manage/disable/opt/'.$override[$i]['val']['oeID'].'/'.$tID.'/" style = "color: #FFF"><div style = "width: 100px; background-color: #2C9EDD; height: 20px; border-radius:5px; padding-top:5px">DISABLE</div></a></td>';
}
elseif ($override[$i]['val']['oeDisable'] == "1" ){
$form .= '<td width = "100" style = "align-content: center">'.createFormElement($field, ($i+1), $field['notNull'], $cnt, $tour, $tID, $override[$i]['val']).'<td width = "50" style = "text-align: center"><a href ="/dashboard/tour_manager/tours/manage/enable/opt/'.$override[$i]['val']['oeID'].'/'.$tID.'/" style = "color: #FFF"><div style = "width: 100px; background-color: #A7072C; height: 20px; border-radius:5px; padding-top:5px">ENABLE</div></a></td>';
}
$z = 0;
$form .= '</tr><tr>';
}
}
}
}
// Disable add/remove functionality if disableAddRemove == true
if ($element[0]['disableAddRemove'] != true) {
//$form .= $fh->hidden($element[0]['formName'] .'_count', $count);
//$form .= '<p><strong>Add/Remove ' .$element[0]['btnText']. '?</strong></p>';
// $form .= '<strong>';
//$form .= '<a href="'.$this->action('add', $element[0]['formName'], $tour_select, $count).'" class="tm-add-field">Add ' . /*rtrim(strtolower($element[0]['formLabel']), ':')*/ 'Traveller' . '..</a><br />';
$form .= '<tr><td>'.$fh->submit($element[0]['formName'] .'_add_submit', 'Add '.$element[0]['btnText'], array('style' => '')).'</tr>';
if ($count > 1) {
$form .= '<tr><td>'.$fh->submit($element[0]['formName'] .'_remove_submit', 'Remove '.$element[0]['btnText'], array('style' => '')).'</tr>';
}
// $form .= '</strong>';
// $form .= '<br /><br />';
}
// reset count
//if (isset(${$fieldCount}) && stripos($fieldCount, $element[0]['formName']) !== false) {
// $count = 1;
// echo $fieldCount;
//}
} else {
// Just a single element
if ($element['dbName'] =='tCurrency'){
$form .= '<tr><td style = "padding-left: 15px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tGuarantee'){
$form2 .= '<td style = "padding-left: 15px; padding-top:7px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tNotes'){
$form .= '<td style = "padding-left: 15px;" rowspan = "2">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tDesc'){
$form .= '<td style = "padding-left: 15px;" rowspan = "2">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['inputType'] == 'date'){
$form2 .= '<tr><td style = "padding-left: 15px; padding-bottom: 10px">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] == 'tGuideNotes'){
$form2 .= '<td colspan = "2" rowspan = "10" float = "right" style = "padding: 10px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['inputType'] == 'textarea'){
$form2 .= '<tr><td colspan = "4" style = "padding: 10px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['inputType'] == 'tourDetailSelect'){
$form .= '<tr><td colspan = "4" style = "padding: 10px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['inputType'] == 'image'){
$form .= '<tr><td colspan = "4" style = "padding: 10px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tStartingPrice'){
$form2 .= '<tr><td colspan = "1" style = "padding-left: 15px; max-width: 40px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tDiscovery'){
$form2 .= '<td colspan = "1" style = "padding-left: 15px; width: 240px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tStudent'){
$form2 .= '<td colspan = "1" style = "padding-left: 15px; width: 240px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tSlashed'){
$form2 .= '<tr><td colspan = "1" style = "padding-left: 15px; max-width: 40px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tIndigo'){
$form2 .= '<td colspan = "1" style = "padding-left: 15px; max-width: 40px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tAdult'){
$form2 .= '<td colspan = "1" style = "padding-left: 15px; max-width: 40px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tLst'){
$form2 .= '<tr><td><td colspan = "1" style = "padding-left: 15px; max-width: 40px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tSenior'){
$form2 .= '<td colspan = "1" style = "padding-left: 15px; max-width: 40px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tCode'){
$form2 .= '<tr><td colspan = "4" style = "padding-top: 15px"><h2 style = "margin-left: 15px">Tour Details</h2><td><tr>';
$form2 .= '<tr><td style = "padding-left: 15px; width: 40px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tName'){
$form2 .= '<td colspan = "2" style = "padding-left: 15px; width: 400px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tTotalSeats'){
$form2 .= '<tr><td style = "padding-left: 15px; padding-top: 40px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tAvailableSeats'){
$form2 .= '<tr></tr><tr><td style = "padding-left: 15px;">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
elseif ($element['dbName'] =='tCurrency'){
$form2 .= '<tr><td>'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID);
}
else{
$form .= '<tr><td colspan ="1">'.createFormElement($element, null, $element['notNull'], $cnt, $tour, $tID).'</td><td>';
}
$form .= '</tr>';
}
// $form .= "<br />";
}
}
//print_r($cnt->getFieldMap());
// Hidden field if neccessary
if($pgMode == 'edit') {
$form .= $fh->hidden('tID', $tID);
//$form .= $fh->hidden('tourCurrency', '£');
// $form .= "<br />";
}
elseif ($_SESSION['templateOn'] === 1){
$_SESSION['tIDtemplate'] = $tID ;
//echo 'working';
}
$btnAttr2 = array('style' => 'width: 230px; height: 40px; margin-bottom: 8px; margin-left: 15px; margin-top: 120px; background: #25A6E1;
margin-right: 20px;
color:#fff;
font-size:17px;
border-radius:4px;
border:none !important;
box-shadow:none !important;
', 'tabindex' => 2);
// Submit
$form2 .= '<tr><td colspan = "1" >'.$fh->submit('tour_submit', 'Submit', $btnAttr2).'</td><tr>';
// Output
$form .= '</table>';
$form2 .= '</table>';
//echo '<div width = "500px" style = "float:left; display: in-line; padding-right: 50px; padding-top:20px;padding-left:10px">';
echo $form2;
$form .= '<div style = "clear:both"></div>';
//echo '</div>';
//echo '<div width = "300px" style = "float:left; display: in-line; padding-top:20px;">';
echo $form;
echo '</br>';
//echo '</div>';
?>
</form>
<div class="ccm-pane-footer"><!-- Footer --> </div>
</div>
</div>
</div>
[/code]
Many thanks for your opinion!
Sorry, that's a massive file..
The parts in question are:
and
The parts in question are:
case 'tourDetailSelect': $pageSelect = Core::make('helper/form/page_selector'); $element .= $pageSelect->selectPage($f['formName'] . $countFormString, $value); break;
and
I just worked it out, all ok!
The code for the file picker was causing some conflict, when I removed all its references the page selector started working, I'll just find a different way to call the file picker in the form.
Thanks anyways!
The code for the file picker was causing some conflict, when I removed all its references the page selector started working, I'll just find a different way to call the file picker in the form.
Thanks anyways!
Nice to hear you figured it out! I've often made posts on concrete5.org as well that I was able to solve on my own before getting an answer here. Hopefully your post will be of help to someone in the future!