list candeleterow plugin error

Status
Not open for further replies.

mahmoodee

Member
Hello,
I am using list candeleterow plugin (PHP eval) to allow user delete their records before 24 hours have passed.
It works fine .
I am using php validation plugin in form date element , but If I enable candeleterow plugin it show this error when adding a new row . If I disable the candeleterow plugin I can add new row with out error.

Code:
DateTime::__construct(): Failed to parse time string (2019-09-28 12:49:29,12:49:29) at position 20 (1): Double time specification
(2019-09-28 12:49:29,12:49:29) is the current date which Iam using in candeleterow plugin .

this is my (PHP eval) code in candeleterow plugin witch work fine in all cases
Code:
$slutDate = new DateTime('{rtable___date_time_raw}');
$myDate1 = new DateTime(date('Y-m-d h:i:s'));
$startDate2 = $myDate1->modify('+4 hours');
$dateDiff = $slutDate->diff($startDate2);
$hours = ($dateDiff->format('%a') * 24) + $dateDiff->format('%h');
$minutes = $dateDiff->format('%i');
return $hours < 24 ;
and this is my code in php validation in date element which work fine only if candeleterow plugin disabled
Code:
$f = '{rtable___date}';
$app = JFactory::getApplication();
$firstTwoCharacters = substr($f, 0, 10);
$c = $app->input->get('rtable___cname_raw');
$first2 = reset($c);
$firstTwoCharacters2=(int)$first2;
$d = $app->input->get('rtable___user2_raw');
$first3 = reset($d);
$firstTwoCharacters3=(int)$first3;

$db = JFactory::getDbo();
  $query = $db->getQuery(true); 
  
  $query = "SELECT COUNT(*) FROM rtable WHERE DATE(CONVERT_TZ(date, '+00:00', '+03:00')) = ". $db->Quote($firstTwoCharacters) . "AND cname=". $db->Quote($firstTwoCharacters2) . "AND user2=". $db->Quote($firstTwoCharacters3); 
  $db->setQuery($query);
  $total = $db->loadResult();
  $total=(int)$total;
 
  if ($total > 0) {
  return false;
  }
  else {return true;}
 
Code:
$slutDate = new DateTime('{rtable___date_time_raw}');
$myDate1 = new DateTime(date('Y-m-d h:i:s'));
$startDate2 = $myDate1->modify('+4 hours');
$dateDiff = $slutDate->diff($startDate2);
$hours = ($dateDiff->format('%a') * 24) + $dateDiff->format('%h');
$minutes = $dateDiff->format('%i');
return $hours < 24 ;

I removed _raw from $slutDate = new DateTime('{rtable___date_time_raw}') and now it work fine without errors
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top