public function configure()
 {
     $this->useFields(array('ig_ref', 'from_date', 'to_date', 'specimen_ref', 'details'));
     $this->widgetSchema['details'] = new sfWidgetFormTextarea(array(), array('rows' => 3));
     $yearsKeyVal = range(1970, intval(sfConfig::get('dw_yearRangeMax')));
     $years = array_combine($yearsKeyVal, $yearsKeyVal);
     $minDate = new FuzzyDateTime(strval(min($yearsKeyVal)) . '/1/1 0:0:0');
     $maxDate = new FuzzyDateTime(strval(max($yearsKeyVal)) . '/12/31 23:59:59');
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $dateUpperBound = new FuzzyDateTime(sfConfig::get('dw_dateUpperBound'));
     $this->widgetSchema['loan_item_ind'] = new sfWidgetFormInputHidden();
     // Indicator of line presence
     $this->setDefault('loan_item_ind', 1);
     $this->validatorSchema['loan_item_ind'] = new sfValidatorPass();
     $this->widgetSchema['loan_ref'] = new sfWidgetFormInputHidden();
     $this->validatorSchema['loan_ref'] = new sfValidatorPass();
     $this->widgetSchema['item_visible'] = new sfWidgetFormInputHidden();
     $this->validatorSchema['item_visible'] = new sfValidatorPass();
     $this->setDefault('item_visible', 'true');
     $this->widgetSchema['from_date'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'with_time' => false), array('class' => 'to_date'));
     $this->validatorSchema['from_date'] = new sfValidatorDate(array('required' => false, 'min' => $minDate->getDateTime(), 'date_format' => 'd/M/Y'), array('invalid' => 'Invalid date "from"'));
     $this->widgetSchema['to_date'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'with_time' => false), array('class' => 'to_date'));
     $this->validatorSchema['to_date'] = new sfValidatorDate(array('required' => false, 'min' => $minDate->getDateTime(), 'date_format' => 'd/M/Y'), array('invalid' => 'Invalid date "return"'));
     $this->widgetSchema['ig_ref'] = new widgetFormInputChecked(array('model' => 'Igs', 'method' => 'getIgNum', 'nullable' => true, 'link_url' => 'igs/searchFor', 'notExistingAddTitle' => $this->getI18N()->__('This I.G. number does not exist. Would you like to automatically insert it ?'), 'notExistingAddValues' => array($this->getI18N()->__('No'), $this->getI18N()->__('Yes'))));
     $this->widgetSchema['specimen_ref'] = new widgetFormButtonRef(array('model' => 'Specimens', 'link_url' => 'specimen/choosePinned', 'method' => 'getId', 'box_title' => $this->getI18N()->__('Choose Darwin item'), 'button_class' => '', 'nullable' => true, 'edit_route' => 'specimen/edit', 'edit_route_params' => array('id')), array('class' => 'inline'));
     $this->widgetSchema->setLabels(array('from_date' => 'Expedition date', 'to_date' => 'Return date'));
     $this->validatorSchema['specimen_ref'] = new sfValidatorInteger(array('required' => false));
     $this->mergePostValidator(new LoanOverviewLineValidatorSchema());
 }
Esempio n. 2
0
 public function configure()
 {
     unset($this['search_indexed']);
     $yearsKeyVal = range(1970, intval(sfConfig::get('dw_yearRangeMax')));
     $years = array_combine($yearsKeyVal, $yearsKeyVal);
     $minDate = new FuzzyDateTime(strval(min($yearsKeyVal)) . '/1/1 0:0:0');
     $maxDate = new FuzzyDateTime(strval(max($yearsKeyVal)) . '/12/31 23:59:59');
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $dateUpperBound = new FuzzyDateTime(sfConfig::get('dw_dateUpperBound'));
     $dateText = array('year' => 'yyyy', 'month' => 'mm', 'day' => 'dd');
     $this->widgetSchema['name'] = new sfWidgetFormInput();
     $this->widgetSchema['from_date'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'with_time' => false, 'empty_values' => $dateText), array('class' => 'from_date'));
     $this->widgetSchema['to_date'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'with_time' => false, 'empty_values' => $dateText), array('class' => 'from_date'));
     $this->widgetSchema['extended_to_date'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'with_time' => false, 'empty_values' => $dateText), array('class' => 'to_date'));
     $this->widgetSchema['sender'] = new sfWidgetFormInputHidden(array('default' => 1));
     $this->widgetSchema['receiver'] = new sfWidgetFormInputHidden(array('default' => 1));
     $this->widgetSchema['users'] = new sfWidgetFormInputHidden(array('default' => 1));
     /* Input file for related files */
     $this->widgetSchema['filenames'] = new sfWidgetFormInputFile();
     $this->widgetSchema['filenames']->setAttributes(array('class' => 'Add_related_file'));
     /*Validators*/
     $this->validatorSchema['name'] = new sfValidatorString(array('required' => true));
     $this->validatorSchema['from_date'] = new sfValidatorDate(array('required' => false, 'min' => $minDate->getDateTime(), 'date_format' => 'd/M/Y'), array('invalid' => 'Invalid date "from"'));
     $this->validatorSchema['to_date'] = new sfValidatorDate(array('required' => false, 'min' => $minDate->getDateTime(), 'date_format' => 'd/M/Y'), array('invalid' => 'Invalid date "to"'));
     $this->validatorSchema['extended_to_date'] = new sfValidatorDate(array('required' => false, 'min' => $minDate->getDateTime(), 'date_format' => 'd/M/Y'), array('invalid' => 'Invalid date "Extended"'));
     $this->validatorSchema['sender'] = new sfValidatorPass();
     $this->validatorSchema['receiver'] = new sfValidatorPass();
     $this->validatorSchema['users'] = new sfValidatorPass();
     //Loan form is submited to upload file, when called like that we don't want some fields to be required
     $this->validatorSchema['filenames'] = new sfValidatorPass();
     $this->mergePostValidator(new LoanValidatorDates());
     /*Labels*/
     $this->widgetSchema->setLabels(array('from_date' => 'Starts on', 'to_date' => 'Ends on', 'filenames' => 'Add File'));
     $this->validatorSchema['Comments_holder'] = new sfValidatorPass();
     $this->widgetSchema['Comments_holder'] = new sfWidgetFormInputHidden(array('default' => 1));
     $this->validatorSchema['RelatedFiles_holder'] = new sfValidatorPass();
     $this->widgetSchema['RelatedFiles_holder'] = new sfWidgetFormInputHidden(array('default' => 1));
     $this->validatorSchema['Insurances_holder'] = new sfValidatorPass();
     $this->widgetSchema['Insurances_holder'] = new sfWidgetFormInputHidden(array('default' => 1));
 }
$t->is($fdt->getDateTime(), $currentDate, 'Get the date coming with the FuzzyDateTime object instanciation');
$t->is($fdt->getDateTime(true), $currentDateTime, 'Get the date and time coming with the FuzzyDateTime object instanciation: ok');
$fdt->setStart(false);
$t->is($fdt->getStart(), false, 'The start value is False');
$fdt->setMask(32);
$t->is($fdt->getMask(), 32, 'The Mask value is 32 (year)');
$fdt = new FuzzyDateTime('1975/02/24 13:12:11');
$testArray = array('year' => 1975, 'month' => 02, 'day' => 24, 'hour' => 13, 'minute' => 12, 'second' => 11);
$dateTimeArray = $fdt->getDateTimeAsArray();
$testDate = '24/02/1975';
$testDateTime = '24/02/1975 13:12:11';
$testDateTime2 = '1975/02/24 13:12:11';
$testDateUS = '02/24/1975';
$t->is_deeply($dateTimeArray, $testArray, 'array is the same');
$fdt->setWithTime(true);
$t->is($fdt->getDateTime($fdt->getWithTime()), $testDateTime, 'Get the date and time coming with the FuzzyDateTime object instanciation: ok');
$t->is($fdt . ' as string', $testDateTime . ' as string', 'String conversion of FuzzyDateTime object is correct');
$fdt->setDateFormat('m/d/Y');
$t->is($fdt->getDateTime(false), $testDateUS, 'New US date formating correctly applied');
$t->is(FuzzyDateTime::getDateTimeStringFromArray($testArray, false, $fdt->getWithTime()), $testDateTime2, 'Full date: Extraction of date from array succeeded !');
$testArray['second'] = '';
$testDateTime2 = '1975/02/24 13:12:59';
$t->is(FuzzyDateTime::getDateTimeStringFromArray($testArray, false, $fdt->getWithTime()), $testDateTime2, 'Date without seconds - start flag set at false: Extraction of date from array succeeded !');
$testArray['minute'] = '';
$testDateTime2 = '1975/02/24 13:59:59';
$t->is(FuzzyDateTime::getDateTimeStringFromArray($testArray, false, $fdt->getWithTime()), $testDateTime2, 'Date without minutes - start flag set at false: Extraction of date from array succeeded !');
$testArray['hour'] = '';
$testDateTime2 = '1975/02/24 23:59:59';
$t->is(FuzzyDateTime::getDateTimeStringFromArray($testArray, false, $fdt->getWithTime()), $testDateTime2, 'Date without hours - start flag set at false: Extraction of date from array succeeded !');
$testArray['day'] = '';
$testDateTime2 = '1975/02/28 23:59:59';
 public function getCreationDate()
 {
     $date = new FuzzyDateTime($this->_get('creation_date'), $this->_get('creation_date_mask'), false, false);
     return $date->getDateTime(null, 'Y/m/d', null);
 }