PHP support.

User 139518 Photo


Ambassador
11 posts

Hi,

I tryied to find suitable forum for this question, but I place it here now. I have make many wonderful forms with you FormBuiler. Thank You.

Next problem is to add number of days to date to develop a new date in database with PHP. Could you please forward this question to the right forum for me.

Thank You,

Janne
User 187934 Photo


Senior Advisor
20,267 posts

Not totally sure what your looking for but this should get you close and the basic concept. Post back if you need more directions.:)
<?php
$Date = date('Y-m-d', strtotime("now") );
echo date('Y-m-d', strtotime($Date. ' + 1 days')); // 1 day from now
echo date('Y-m-d', strtotime($Date. ' + 2 days')); // 2 days from now
?>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 139518 Photo


Ambassador
11 posts

Thank You for your reply. Here is some more details:


In events inOnbeforeUpdateRecords, I have made code

"$rowData['huoltoseuraava'] = $rowData['huoltotehty'] +60*60*24*$rowData['huoltovali'];"
(PHP Generator for MySQL Professional)


When I change number of dates "huoltovali" to add to original date it does not go right.


The first date here is the previous "service date", in the middle is number of days to next service, and the last box suppoused to be the calculated next date for the service.
29.11.2013 201,0 27.11.6401
29.11.2013 200,0 01.12.1727

29.11.2013 100,0 01.01.8640
29.11.2013 50,0 01.01.4320

29.11.2013 10,0 01.01.1970
The date format in sql table is 2013-11-29 00:00:00


I have used WebFormBuilder a lot make different solutions. SQL database I have tried to cope with PHP Generator from sqlmaestro.com. I can make things work with this program but now it looks like too complicated to me.

From SQL maestro I received this link below

http://www.sqlmaestro.com/products/mysq … rator/faq/

I hope you could understand this case better now.

Thanks for taking time to help people.

Janne
User 187934 Photo


Senior Advisor
20,267 posts

I would take a look at this.
http://www.sqlmaestro.com/products/mysq … ta_format/
I don't use any php gui. I hand code in the html editor so I'm in control of what a variable looks like. Should be just a matter of formatting.;)
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 139518 Photo


Ambassador
11 posts

Thank you for the hint. I have tried to study this subject but I won't get any further.

Here below is something I have tested with my poor PHP knowledge. First I have pasted the date calculation part and then hole service.php


function serviceGrid_BeforeUpdateRecord($page, &$rowData, &$cancel, &$message, $tableName)
{
$rowData['service_made'] = date(d.m.Y);
$rowData['next_service_date'] = date(d.m.Y);
$rowData['next_service_date'] = $rowData['service_made'] + (60*60*24* $rowData['number_days_to_next_service']);
}


-----


<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* ATTENTION!
* If you see this message in your browser (Internet Explorer, Mozilla Firefox, Google Chrome, etc.)
* this means that PHP is not properly installed on your web server. Please refer to the PHP manual
* for more details: http://php.net/manual/install.php
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/


require_once 'components/utils/check_utils.php';
CheckPHPVersion();
CheckTemplatesCacheFolderIsExistsAndWritable();



require_once 'phpgen_settings.php';
require_once 'database_engine/mysql_engine.php';
require_once 'components/page.php';


function GetConnectionOptions()
{
$result = GetGlobalConnectionOptions();
GetApplication()->GetUserAuthorizationStrategy()->ApplyIdentityToConnectionOptions($result);
return $result;
}



// OnBeforePageExecute event handler



class servicePage extends Page
{
protected function DoBeforeCreate()
{
$this->dataset = new TableDataset(
new MyConnectionFactory(),
GetConnectionOptions(),
'`service`');
$field = new IntegerField('_rowid_', null, null, true);
$field->SetIsNotNull(true);
$this->dataset->AddField($field, true);
$field = new DateField('service_made');
$field->SetIsNotNull(true);
$this->dataset->AddField($field, false);
$field = new IntegerField('number_days_to_next_service');
$this->dataset->AddField($field, false);
$field = new DateField('next_service_date');
$field->SetIsNotNull(true);
$this->dataset->AddField($field, false);
$field = new DateTimeField('_submitted_');
$field->SetIsNotNull(true);
$this->dataset->AddField($field, false);
$field = new StringField('_fromaddress_');
$field->SetIsNotNull(true);
$this->dataset->AddField($field, false);
$field = new IntegerField('_flags_');
$field->SetIsNotNull(true);
$this->dataset->AddField($field, false);
$field = new StringField('_transactid_');
$field->SetIsNotNull(true);
$this->dataset->AddField($field, false);
}

protected function CreatePageNavigator()
{
$result = new CompositePageNavigator($this);

$partitionNavigator = new PageNavigator('pnav', $this, $this->dataset);
$partitionNavigator->SetRowsPerPage(20);
$result->AddPageNavigator($partitionNavigator);

return $result;
}

public function GetPageList()
{
$currentPageCaption = $this->GetShortCaption();
$result = new PageList($this);
if (GetCurrentUserGrantForDataSource('service')->HasViewGrant())
$result->AddPage(new PageLink($this->RenderText('Service'), 'service.php', $this->RenderText('Service'), $currentPageCaption == $this->RenderText('Service')));

if ( HasAdminPage() && GetApplication()->HasAdminGrantForCurrentUser() )
$result->AddPage(new PageLink($this->GetLocalizerCaptions()->GetMessageString('AdminPage'), 'phpgen_admin.php', $this->GetLocalizerCaptions()->GetMessageString('AdminPage'), false, true));
return $result;
}

protected function CreateRssGenerator()
{
return null;
}

protected function CreateGridSearchControl($grid)
{
$grid->UseFilter = true;
$grid->SearchControl = new SimpleSearch('servicessearch', $this->dataset,
array('_rowid_', 'service_made', 'number_days_to_next_service', 'next_service_date', '_submitted_'),
array($this->RenderText(' Rowid '), $this->RenderText('Service Made'), $this->RenderText('Number Days To Next Service'), $this->RenderText('Next Service Date'), $this->RenderText(' Submitted ')),
array(
'=' => $this->GetLocalizerCaptions()->GetMessageString('equals'),
'<>' => $this->GetLocalizerCaptions()->GetMessageString('doesNotEquals'),
'<' => $this->GetLocalizerCaptions()->GetMessageString('isLessThan'),
'<=' => $this->GetLocalizerCaptions()->GetMessageString('isLessThanOrEqualsTo'),
'>' => $this->GetLocalizerCaptions()->GetMessageString('isGreaterThan'),
'>=' => $this->GetLocalizerCaptions()->GetMessageString('isGreaterThanOrEqualsTo'),
'ILIKE' => $this->GetLocalizerCaptions()->GetMessageString('Like'),
'STARTS' => $this->GetLocalizerCaptions()->GetMessageString('StartsWith'),
'ENDS' => $this->GetLocalizerCaptions()->GetMessageString('EndsWith'),
'CONTAINS' => $this->GetLocalizerCaptions()->GetMessageString('Contains')
), $this->GetLocalizerCaptions(), $this, 'CONTAINS'
);
}

protected function CreateGridAdvancedSearchControl($grid)
{
$this->AdvancedSearchControl = new AdvancedSearchControl('serviceasearch', $this->dataset, $this->GetLocalizerCaptions(), $this->GetColumnVariableContainer(), $this->CreateLinkBuilder());
$this->AdvancedSearchControl->AddSearchColumn($this->AdvancedSearchControl->CreateStringSearchInput('_rowid_', $this->RenderText(' Rowid ')));
$this->AdvancedSearchControl->AddSearchColumn($this->AdvancedSearchControl->CreateDateTimeSearchInput('service_made', $this->RenderText('Service Made')));
$this->AdvancedSearchControl->AddSearchColumn($this->AdvancedSearchControl->CreateStringSearchInput('number_days_to_next_service', $this->RenderText('Number Days To Next Service')));
$this->AdvancedSearchControl->AddSearchColumn($this->AdvancedSearchControl->CreateDateTimeSearchInput('next_service_date', $this->RenderText('Next Service Date')));
$this->AdvancedSearchControl->AddSearchColumn($this->AdvancedSearchControl->CreateDateTimeSearchInput('_submitted_', $this->RenderText(' Submitted ')));
}

protected function AddOperationsColumns($grid)
{
$actionsBandName = 'actions';
$grid->AddBand($actionsBandName, $this->GetLocalizerCaptions()->GetMessageString('Actions'), true);
if ($this->GetSecurityInfo()->HasViewGrant())
{
$column = $grid->AddViewColumn(new RowOperationByLinkColumn($this->GetLocalizerCaptions()->GetMessageString('View'), OPERATION_VIEW, $this->dataset), $actionsBandName);
$column->SetImagePath('images/view_action.png');
}
if ($this->GetSecurityInfo()->HasEditGrant())
{
$column = $grid->AddViewColumn(new RowOperationByLinkColumn($this->GetLocalizerCaptions()->GetMessageString('Edit'), OPERATION_EDIT, $this->dataset), $actionsBandName);
$column->SetImagePath('images/edit_action.png');
$column->OnShow->AddListener('ShowEditButtonHandler', $this);
}
if ($this->GetSecurityInfo()->HasDeleteGrant())
{
$column = $grid->AddViewColumn(new RowOperationByLinkColumn($this->GetLocalizerCaptions()->GetMessageString('Delete'), OPERATION_DELETE, $this->dataset), $actionsBandName);
$column->SetImagePath('images/delete_action.png');
$column->OnShow->AddListener('ShowDeleteButtonHandler', $this);
$column->SetAdditionalAttribute("data-modal-delete", "true");
$column->SetAdditionalAttribute("data-delete-handler-name", $this->GetModalGridDeleteHandler());
}
if ($this->GetSecurityInfo()->HasAddGrant())
{
$column = $grid->AddViewColumn(new RowOperationByLinkColumn($this->GetLocalizerCaptions()->GetMessageString('Copy'), OPERATION_COPY, $this->dataset), $actionsBandName);
$column->SetImagePath('images/copy_action.png');
}
}

protected function AddFieldColumns($grid)
{
//
// View column for _rowid_ field
//
$column = new TextViewColumn('_rowid_', ' Rowid ', $this->dataset);
$column->SetOrderable(true);
$column->SetDescription($this->RenderText(''));
$column->SetFixedWidth(null);
$grid->AddViewColumn($column);

//
// View column for service_made field
//
$column = new DateTimeViewColumn('service_made', 'Service Made', $this->dataset);
$column->SetDateTimeFormat('d.m.Y h:s:i');
$column->SetOrderable(true);

/* <inline edit column> */
//
// Edit column for service_made field
//
$editor = new DateTimeEdit('service_made_edit', true, 'Y-m-d H:i:s', GetFirstDayOfWeek());
$editColumn = new CustomEditColumn('Service Made', 'service_made', $editor, $this->dataset);
$validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
$editor->GetValidatorCollection()->AddValidator($validator);
$this->ApplyCommonColumnEditProperties($editColumn);
$column->SetEditOperationColumn($editColumn);
/* </inline edit column> */

/* <inline insert column> */
//
// Edit column for service_made field
//
$editor = new DateTimeEdit('service_made_edit', true, 'Y-m-d H:i:s', GetFirstDayOfWeek());
$editColumn = new CustomEditColumn('Service Made', 'service_made', $editor, $this->dataset);
$editColumn->SetAllowSetToDefault(true);
$validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
$editor->GetValidatorCollection()->AddValidator($validator);
$this->ApplyCommonColumnEditProperties($editColumn);
$column->SetInsertOperationColumn($editColumn);
/* </inline insert column> */
$column->SetDescription($this->RenderText(''));
$column->SetFixedWidth(null);
$grid->AddViewColumn($column);

//
// View column for number_days_to_next_service field
//
$column = new TextViewColumn('number_days_to_next_service', 'Number Days To Next Service', $this->dataset);
$column->SetOrderable(true);

/* <inline edit column> */
//
// Edit column for number_days_to_next_service field
//
$editor = new TextEdit('number_days_to_next_service_edit');
$editColumn = new CustomEditColumn('Number Days To Next Service', 'number_days_to_next_service', $editor, $this->dataset);
$editColumn->SetAllowSetToNull(true);
$this->ApplyCommonColumnEditProperties($editColumn);
$column->SetEditOperationColumn($editColumn);
/* </inline edit column> */

/* <inline insert column> */
//
// Edit column for number_days_to_next_service field
//
$editor = new TextEdit('number_days_to_next_service_edit');
$editColumn = new CustomEditColumn('Number Days To Next Service', 'number_days_to_next_service', $editor, $this->dataset);
$editColumn->SetAllowSetToNull(true);
$this->ApplyCommonColumnEditProperties($editColumn);
$column->SetInsertOperationColumn($editColumn);
/* </inline insert column> */
$column->SetDescription($this->RenderText(''));
$column->SetFixedWidth(null);
$grid->AddViewColumn($column);

//
// View column for next_service_date field
//
$column = new DateTimeViewColumn('next_service_date', 'Next Service Date', $this->dataset);
$column->SetDateTimeFormat('d.m.Y h:s:i');
$column->SetOrderable(true);

/* <inline edit column> */
//
// Edit column for next_service_date field
//
$editor = new DateTimeEdit('next_service_date_edit', true, 'Y-m-d H:i:s', GetFirstDayOfWeek());
$editColumn = new CustomEditColumn('Next Service Date', 'next_service_date', $editor, $this->dataset);
$validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
$editor->GetValidatorCollection()->AddValidator($validator);
$this->ApplyCommonColumnEditProperties($editColumn);
$column->SetEditOperationColumn($editColumn);
/* </inline edit column> */

/* <inline insert column> */
//
// Edit column for next_service_date field
//
$editor = new DateTimeEdit('next_service_date_edit', true, 'Y-m-d H:i:s', GetFirstDayOfWeek());
$editColumn = new CustomEditColumn('Next Service Date', 'next_service_date', $editor, $this->dataset);
$editColumn->SetAllowSetToDefault(true);
$validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
$editor->GetValidatorCollection()->AddValidator($validator);
$this->ApplyCommonColumnEditProperties($editColumn);
$column->SetInsertOperationColumn($editColumn);
/* </inline insert column> */
$column->SetDescription($this->RenderText(''));
$column->SetFixedWidth(null);
$grid->AddViewColumn($column);

//
// View column for _submitted_ field
//
$column = new DateTimeViewColumn('_submitted_', ' Submitted ', $this->dataset);
$column->SetDateTimeFormat('d.m.Y h:s:i');
$column->SetOrderable(true);

/* <inline edit column> */
//
// Edit column for _submitted_ field
//
$editor = new DateTimeEdit('_submitted__edit', true, 'Y-m-d H:i:s', GetFirstDayOfWeek());
$editColumn = new CustomEditColumn(' Submitted ', '_submitted_', $editor, $this->dataset);
$validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
$editor->GetValidatorCollection()->AddValidator($validator);
$this->ApplyCommonColumnEditProperties($editColumn);
$column->SetEditOperationColumn($editColumn);
/* </inline edit column> */

/* <inline insert column> */
//
// Edit column for _submitted_ field
//
$editor = new DateTimeEdit('_submitted__edit', true, 'Y-m-d H:i:s', GetFirstDayOfWeek());
$editColumn = new CustomEditColumn(' Submitted ', '_submitted_', $editor, $this->dataset);
$editColumn->SetAllowSetToDefault(true);
$validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
$editor->GetValidatorCollection()->AddValidator($validator);
$this->ApplyCommonColumnEditProperties($editColumn);
$column->SetInsertOperationColumn($editColumn);
/* </inline insert column> */
$column->SetDescription($this->RenderText(''));
$column->SetFixedWidth(null);
$grid->AddViewColumn($column);
}

protected function AddSingleRecordViewColumns($grid)
{
//
// View column for _rowid_ field
//
$column = new TextViewColumn('_rowid_', ' Rowid ', $this->dataset);
$column->SetOrderable(true);
$grid->AddSingleRecordViewColumn($column);

//
// View column for service_made field
//
$column = new DateTimeViewColumn('service_made', 'Service Made', $this->dataset);
$column->SetDateTimeFormat('d.m.Y h:s:i');
$column->SetOrderable(true);
$grid->AddSingleRecordViewColumn($column);

//
// View column for number_days_to_next_service field
//
$column = new TextViewColumn('number_days_to_next_service', 'Number Days To Next Service', $this->dataset);
$column->SetOrderable(true);
$grid->AddSingleRecordViewColumn($column);

//
// View column for next_service_date field
//
$column = new DateTimeViewColumn('next_service_date', 'Next Service Date', $this->dataset);
$column->SetDateTimeFormat('d.m.Y h:s:i');
$column->SetOrderable(true);
$grid->AddSingleRecordViewColumn($column);

//
// View column for _submitted_ field
//
$column = new DateTimeViewColumn('_submitted_', ' Submitted ', $this->dataset);
$column->SetDateTimeFormat('d.m.Y h:s:i');
$column->SetOrderable(true);
$grid->AddSingleRecordViewColumn($column);
}

protected function AddEditColumns($grid)
{
//
// Edit column for service_made field
//
$editor = new DateTimeEdit('service_made_edit', true, 'Y-m-d H:i:s', GetFirstDayOfWeek());
$editColumn = new CustomEditColumn('Service Made', 'service_made', $editor, $this->dataset);
$validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
$editor->GetValidatorCollection()->AddValidator($validator);
$this->ApplyCommonColumnEditProperties($editColumn);
$grid->AddEditColumn($editColumn);

//
// Edit column for number_days_to_next_service field
//
$editor = new TextEdit('number_days_to_next_service_edit');
$editColumn = new CustomEditColumn('Number Days To Next Service', 'number_days_to_next_service', $editor, $this->dataset);
$editColumn->SetAllowSetToNull(true);
$this->ApplyCommonColumnEditProperties($editColumn);
$grid->AddEditColumn($editColumn);

//
// Edit column for next_service_date field
//
$editor = new DateTimeEdit('next_service_date_edit', true, 'Y-m-d H:i:s', GetFirstDayOfWeek());
$editColumn = new CustomEditColumn('Next Service Date', 'next_service_date', $editor, $this->dataset);
$validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
$editor->GetValidatorCollection()->AddValidator($validator);
$this->ApplyCommonColumnEditProperties($editColumn);
$grid->AddEditColumn($editColumn);

//
// Edit column for _submitted_ field
//
$editor = new DateTimeEdit('_submitted__edit', true, 'Y-m-d H:i:s', GetFirstDayOfWeek());
$editColumn = new CustomEditColumn(' Submitted ', '_submitted_', $editor, $this->dataset);
$validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
$editor->GetValidatorCollection()->AddValidator($validator);
$this->ApplyCommonColumnEditProperties($editColumn);
$grid->AddEditColumn($editColumn);
}

protected function AddInsertColumns($grid)
{
//
// Edit column for service_made field
//
$editor = new DateTimeEdit('service_made_edit', true, 'Y-m-d H:i:s', GetFirstDayOfWeek());
$editColumn = new CustomEditColumn('Service Made', 'service_made', $editor, $this->dataset);
$editColumn->SetAllowSetToDefault(true);
$validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
$editor->GetValidatorCollection()->AddValidator($validator);
$this->ApplyCommonColumnEditProperties($editColumn);
$grid->AddInsertColumn($editColumn);

//
// Edit column for number_days_to_next_service field
//
$editor = new TextEdit('number_days_to_next_service_edit');
$editColumn = new CustomEditColumn('Number Days To Next Service', 'number_days_to_next_service', $editor, $this->dataset);
$editColumn->SetAllowSetToNull(true);
$this->ApplyCommonColumnEditProperties($editColumn);
$grid->AddInsertColumn($editColumn);

//
// Edit column for next_service_date field
//
$editor = new DateTimeEdit('next_service_date_edit', true, 'Y-m-d H:i:s', GetFirstDayOfWeek());
$editColumn = new CustomEditColumn('Next Service Date', 'next_service_date', $editor, $this->dataset);
$editColumn->SetAllowSetToDefault(true);
$validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
$editor->GetValidatorCollection()->AddValidator($validator);
$this->ApplyCommonColumnEditProperties($editColumn);
$grid->AddInsertColumn($editColumn);

//
// Edit column for _submitted_ field
//
$editor = new DateTimeEdit('_submitted__edit', true, 'Y-m-d H:i:s', GetFirstDayOfWeek());
$editColumn = new CustomEditColumn(' Submitted ', '_submitted_', $editor, $this->dataset);
$editColumn->SetAllowSetToDefault(true);
$validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
$editor->GetValidatorCollection()->AddValidator($validator);
$this->ApplyCommonColumnEditProperties($editColumn);
$grid->AddInsertColumn($editColumn);
if ($this->GetSecurityInfo()->HasAddGrant())
{
$grid->SetShowAddButton(true);
$grid->SetShowInlineAddButton(false);
}
else
{
$grid->SetShowInlineAddButton(false);
$grid->SetShowAddButton(false);
}
}

protected function AddPrintColumns($grid)
{
//
// View column for _rowid_ field
//
$column = new TextViewColumn('_rowid_', ' Rowid ', $this->dataset);
$column->SetOrderable(true);
$grid->AddPrintColumn($column);

//
// View column for service_made field
//
$column = new DateTimeViewColumn('service_made', 'Service Made', $this->dataset);
$column->SetDateTimeFormat('d.m.Y h:s:i');
$column->SetOrderable(true);
$grid->AddPrintColumn($column);

//
// View column for number_days_to_next_service field
//
$column = new TextViewColumn('number_days_to_next_service', 'Number Days To Next Service', $this->dataset);
$column->SetOrderable(true);
$grid->AddPrintColumn($column);

//
// View column for next_service_date field
//
$column = new DateTimeViewColumn('next_service_date', 'Next Service Date', $this->dataset);
$column->SetDateTimeFormat('d.m.Y h:s:i');
$column->SetOrderable(true);
$grid->AddPrintColumn($column);

//
// View column for _submitted_ field
//
$column = new DateTimeViewColumn('_submitted_', ' Submitted ', $this->dataset);
$column->SetDateTimeFormat('d.m.Y h:s:i');
$column->SetOrderable(true);
$grid->AddPrintColumn($column);
}

protected function AddExportColumns($grid)
{
//
// View column for _rowid_ field
//
$column = new TextViewColumn('_rowid_', ' Rowid ', $this->dataset);
$column->SetOrderable(true);
$grid->AddExportColumn($column);

//
// View column for service_made field
//
$column = new DateTimeViewColumn('service_made', 'Service Made', $this->dataset);
$column->SetDateTimeFormat('d.m.Y h:s:i');
$column->SetOrderable(true);
$grid->AddExportColumn($column);

//
// View column for number_days_to_next_service field
//
$column = new TextViewColumn('number_days_to_next_service', 'Number Days To Next Service', $this->dataset);
$column->SetOrderable(true);
$grid->AddExportColumn($column);

//
// View column for next_service_date field
//
$column = new DateTimeViewColumn('next_service_date', 'Next Service Date', $this->dataset);
$column->SetDateTimeFormat('d.m.Y h:s:i');
$column->SetOrderable(true);
$grid->AddExportColumn($column);

//
// View column for _submitted_ field
//
$column = new DateTimeViewColumn('_submitted_', ' Submitted ', $this->dataset);
$column->SetDateTimeFormat('d.m.Y h:s:i');
$column->SetOrderable(true);
$grid->AddExportColumn($column);
}

public function GetPageDirection()
{
return null;
}

protected function ApplyCommonColumnEditProperties($column)
{
$column->SetShowSetToNullCheckBox(false);
$column->SetVariableContainer($this->GetColumnVariableContainer());
}

function GetCustomClientScript()
{
return ;
}

function GetOnPageLoadedClientScript()
{
return ;
}
function serviceGrid_BeforeUpdateRecord($page, &$rowData, &$cancel, &$message, $tableName)
{
$rowData['service_made'] = date(d.m.Y);
$rowData['next_service_date'] = date(d.m.Y);
$rowData['next_service_date'] = $rowData['service_made'] + (60*60*24* $rowData['number_days_to_next_service']);
}
public function ShowEditButtonHandler(&$show)
{
if ($this->GetRecordPermission() != null)
$show = $this->GetRecordPermission()->HasEditGrant($this->GetDataset());
}
public function ShowDeleteButtonHandler(&$show)
{
if ($this->GetRecordPermission() != null)
$show = $this->GetRecordPermission()->HasDeleteGrant($this->GetDataset());
}

public function GetModalGridDeleteHandler() { return 'service_modal_delete'; }
protected function GetEnableModalGridDelete() { return true; }

protected function CreateGrid()
{
$result = new Grid($this, $this->dataset, 'serviceGrid');
if ($this->GetSecurityInfo()->HasDeleteGrant())
$result->SetAllowDeleteSelected(true);
else
$result->SetAllowDeleteSelected(false);

ApplyCommonPageSettings($this, $result);

$result->SetUseImagesForActions(true);
$result->SetUseFixedHeader(false);

$result->SetShowLineNumbers(false);

$result->SetHighlightRowAtHover(true);
$result->SetWidth('');
$result->BeforeUpdateRecord->AddListener('serviceGrid' . '_' . 'BeforeUpdateRecord', $this);
$this->CreateGridSearchControl($result);
$this->CreateGridAdvancedSearchControl($result);

$this->AddFieldColumns($result);
$this->AddSingleRecordViewColumns($result);
$this->AddEditColumns($result);
$this->AddInsertColumns($result);
$this->AddPrintColumns($result);
$this->AddExportColumns($result);
$this->AddOperationsColumns($result);
$this->SetShowPageList(true);
$this->SetHidePageListByDefault(false);
$this->SetExportToExcelAvailable(true);
$this->SetExportToWordAvailable(true);
$this->SetExportToXmlAvailable(false);
$this->SetExportToCsvAvailable(false);
$this->SetExportToPdfAvailable(true);
$this->SetPrinterFriendlyAvailable(true);
$this->SetSimpleSearchAvailable(true);
$this->SetAdvancedSearchAvailable(false);
$this->SetFilterRowAvailable(true);
$this->SetVisualEffectsEnabled(true);
$this->SetShowTopPageNavigator(true);
$this->SetShowBottomPageNavigator(true);

//
// Http Handlers
//

return $result;
}

public function OpenAdvancedSearchByDefault()
{
return false;
}

protected function DoGetGridHeader()
{
return '';
}
}



try
{
$Page = new servicePage("service.php", "service", GetCurrentUserGrantForDataSource("service"), GetAnsiEncoding());
$Page->SetShortCaption('Service');
$Page->SetHeader(GetPagesHeader());
$Page->SetFooter(GetPagesFooter());
$Page->SetCaption('Service');
$Page->SetRecordPermission(GetCurrentUserRecordPermissionsForDataSource("service"));

GetApplication()->SetMainPage($Page);
GetApplication()->Run();
}
catch(Exception $e)
{
ShowErrorPage($e->getMessage());
}

User 139518 Photo


Ambassador
11 posts

Thanks Eric, you helped me to the right direction.
The problem is solved:


$rowData['service_made'] = date("d.m.Y");
$seuraava = time() + (60*60*24* $rowData['number_days_to_next_service']);
$seuraava = date("d.m.Y", $seuraava);
$rowData['next_service_date'] = $seuraava;
User 464893 Photo


Ambassador
1,611 posts

One point I would like to make. Get each variable populated that you want in your report and work through the combinations.Helps to simplify the calculations and remember to comment it well for later
The Guy from OZ



Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.