@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | foreach($input as $k=>$v){ |
| 281 | 281 | $return[utf8_decode($k)] = app_utf8Decode($v); |
| 282 | 282 | } |
| 283 | - }else{ |
|
| 283 | + } else{ |
|
| 284 | 284 | return utf8_decode($input); |
| 285 | 285 | } |
| 286 | 286 | return $return; |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | foreach($input as $k=>$v){ |
| 293 | 293 | $return[app_utf8Encode($k)] = app_utf8Encode($v); |
| 294 | 294 | } |
| 295 | - }else{ |
|
| 295 | + } else{ |
|
| 296 | 296 | return utf8_encode($input); |
| 297 | 297 | } |
| 298 | 298 | return $return; |
@@ -180,8 +180,7 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | /*@var $customfield AppCustomField */ |
| 182 | 182 | } |
| 183 | - } |
|
| 184 | - catch (ORMBackEndSelectException $e){ |
|
| 183 | + } catch (ORMBackEndSelectException $e){ |
|
| 185 | 184 | // table does not exist, this error is thrown by the install program while creating the sets |
| 186 | 185 | } |
| 187 | 186 | } |
@@ -218,8 +217,7 @@ discard block |
||
| 218 | 217 | if($ormField instanceof ORMFkField){ |
| 219 | 218 | $this->hasOne($customField->fieldname, $ormField->getForeignSetName()) |
| 220 | 219 | ->setDescription($description); |
| 221 | - } |
|
| 222 | - else{ |
|
| 220 | + } else{ |
|
| 223 | 221 | $this->addFields($ormField); |
| 224 | 222 | } |
| 225 | 223 | } |
@@ -282,8 +280,7 @@ discard block |
||
| 282 | 280 | |
| 283 | 281 | if(is_array($source) || ($source instanceof \Iterator)){ |
| 284 | 282 | return $linkSet->selectForSources($source, $targetClass, $linkType); |
| 285 | - } |
|
| 286 | - else{ |
|
| 283 | + } else{ |
|
| 287 | 284 | return $linkSet->selectForSource($source, $targetClass, $linkType); |
| 288 | 285 | } |
| 289 | 286 | } |
@@ -309,8 +306,7 @@ discard block |
||
| 309 | 306 | |
| 310 | 307 | if(is_array($target) || ($target instanceof \Iterator)){ |
| 311 | 308 | return $linkSet->selectForTargets($target, $sourceClass, $linkType); |
| 312 | - } |
|
| 313 | - else{ |
|
| 309 | + } else{ |
|
| 314 | 310 | return $linkSet->selectForTarget($target, $sourceClass, $linkType); |
| 315 | 311 | } |
| 316 | 312 | } |
@@ -345,8 +341,7 @@ discard block |
||
| 345 | 341 | if(isset($linkType)){ |
| 346 | 342 | if(is_array($linkType)){ |
| 347 | 343 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 348 | - } |
|
| 349 | - else{ |
|
| 344 | + } else{ |
|
| 350 | 345 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 351 | 346 | } |
| 352 | 347 | } |
@@ -389,8 +384,7 @@ discard block |
||
| 389 | 384 | if(isset($linkType)){ |
| 390 | 385 | if(is_array($linkType)){ |
| 391 | 386 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 392 | - } |
|
| 393 | - else{ |
|
| 387 | + } else{ |
|
| 394 | 388 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 395 | 389 | } |
| 396 | 390 | } |
@@ -443,8 +437,7 @@ discard block |
||
| 443 | 437 | if(isset($linkType)){ |
| 444 | 438 | if(is_array($linkType)){ |
| 445 | 439 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 446 | - } |
|
| 447 | - else{ |
|
| 440 | + } else{ |
|
| 448 | 441 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 449 | 442 | } |
| 450 | 443 | } |
@@ -497,8 +490,7 @@ discard block |
||
| 497 | 490 | if(isset($linkType)){ |
| 498 | 491 | if(is_array($linkType)){ |
| 499 | 492 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 500 | - } |
|
| 501 | - else{ |
|
| 493 | + } else{ |
|
| 502 | 494 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 503 | 495 | } |
| 504 | 496 | } |
@@ -615,8 +607,7 @@ discard block |
||
| 615 | 607 | |
| 616 | 608 | if(is_array($tagLabels)){ |
| 617 | 609 | $criteria = $criteria->_AND_($linkSet->targetId->label->in($tagLabels)); |
| 618 | - } |
|
| 619 | - else{ |
|
| 610 | + } else{ |
|
| 620 | 611 | $criteria = $criteria->_AND_($linkSet->targetId->label->is($tagLabels)); |
| 621 | 612 | } |
| 622 | 613 | if(isset($linkType)){ |
@@ -652,7 +643,7 @@ discard block |
||
| 652 | 643 | public function getDisplayNameField(){ |
| 653 | 644 | if($this->fieldExist("name")){ |
| 654 | 645 | return $this->name; |
| 655 | - }else{ |
|
| 646 | + } else{ |
|
| 656 | 647 | return $this->id; |
| 657 | 648 | } |
| 658 | 649 | } |
@@ -352,7 +352,7 @@ |
||
| 352 | 352 | public function getDisplayNameField(){ |
| 353 | 353 | if($this->fieldExist("name")){ |
| 354 | 354 | return $this->name; |
| 355 | - }else{ |
|
| 355 | + } else{ |
|
| 356 | 356 | return $this->uuid; |
| 357 | 357 | } |
| 358 | 358 | } |
@@ -51,8 +51,7 @@ |
||
| 51 | 51 | return null; |
| 52 | 52 | } |
| 53 | 53 | return \bab_functionality::get($composerjson['appFunctionality']); |
| 54 | - } |
|
| 55 | - catch (\Exception $e){ |
|
| 54 | + } catch (\Exception $e){ |
|
| 56 | 55 | return null; |
| 57 | 56 | } |
| 58 | 57 | } |
@@ -2141,7 +2141,7 @@ |
||
| 2141 | 2141 | } |
| 2142 | 2142 | |
| 2143 | 2143 | header("Content-type: application/json; charset=utf-8"); |
| 2144 | - echo $collection->output(); |
|
| 2145 | - die(); |
|
| 2144 | + echo $collection->output(); |
|
| 2145 | + die(); |
|
| 2146 | 2146 | } |
| 2147 | 2147 | } |
@@ -59,50 +59,50 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | function app_genericSetEditor(ORMRecordSet $set) |
| 61 | 61 | { |
| 62 | - $O = \bab_functionality::get('LibOrm'); |
|
| 63 | - $O->init(); |
|
| 64 | - $W = \bab_Widgets(); |
|
| 65 | - $layout = $W->VBoxLayout(); |
|
| 66 | - $layout->setVerticalSpacing(1, 'em'); |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - $fields = $set->getFields(); |
|
| 70 | - |
|
| 71 | - foreach ($fields as $field) { |
|
| 72 | - $description = $field->getDescription(); |
|
| 73 | - if (empty($description)) { |
|
| 74 | - $description = $field->getName(); |
|
| 75 | - } |
|
| 76 | - $fieldLabel = $W->Label($description . ':'); |
|
| 77 | - |
|
| 78 | - if ($field instanceof ORMDateField) { |
|
| 79 | - $widget = $W->DatePicker(); |
|
| 80 | - } else if ($field instanceof ORMTimeField) { |
|
| 81 | - $widget = $W->LineEdit()->setMaxSize(5)->setSize(5)->addClass('widget-timepicker'); |
|
| 82 | - } else if ($field instanceof ORMStringField) { |
|
| 83 | - $widget = $W->LineEdit()->setSize(min(array(80, $field->getMaxLength()))); |
|
| 84 | - } else if ($field instanceof ORMEnumField) { |
|
| 85 | - $widget = $W->Select(); |
|
| 86 | - $widget->addOption('', ''); |
|
| 87 | - foreach ($field->getValues() as $key => $text) { |
|
| 88 | - $widget->addOption($key, $text); |
|
| 89 | - } |
|
| 90 | - } else if ($field instanceof ORMIntField) { |
|
| 91 | - $widget = $W->LineEdit()->setSize(9); |
|
| 92 | - } else if ($field instanceof ORMTextField) { |
|
| 93 | - $widget = $W->TextEdit()->setColumns(80)->setLines(5); |
|
| 94 | - } else if ($field instanceof ORMRecordSet) { |
|
| 95 | - $widget = app_genericSetEditor($field); |
|
| 96 | - $widget->addClass('sub-form'); |
|
| 97 | - } else { |
|
| 98 | - $widget = null; |
|
| 99 | - } |
|
| 100 | - if (isset($widget)) { |
|
| 101 | - $layout->addItem($W->VBoxLayout()->addItem($fieldLabel)->addItem($widget)); |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - return $layout; |
|
| 62 | + $O = \bab_functionality::get('LibOrm'); |
|
| 63 | + $O->init(); |
|
| 64 | + $W = \bab_Widgets(); |
|
| 65 | + $layout = $W->VBoxLayout(); |
|
| 66 | + $layout->setVerticalSpacing(1, 'em'); |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + $fields = $set->getFields(); |
|
| 70 | + |
|
| 71 | + foreach ($fields as $field) { |
|
| 72 | + $description = $field->getDescription(); |
|
| 73 | + if (empty($description)) { |
|
| 74 | + $description = $field->getName(); |
|
| 75 | + } |
|
| 76 | + $fieldLabel = $W->Label($description . ':'); |
|
| 77 | + |
|
| 78 | + if ($field instanceof ORMDateField) { |
|
| 79 | + $widget = $W->DatePicker(); |
|
| 80 | + } else if ($field instanceof ORMTimeField) { |
|
| 81 | + $widget = $W->LineEdit()->setMaxSize(5)->setSize(5)->addClass('widget-timepicker'); |
|
| 82 | + } else if ($field instanceof ORMStringField) { |
|
| 83 | + $widget = $W->LineEdit()->setSize(min(array(80, $field->getMaxLength()))); |
|
| 84 | + } else if ($field instanceof ORMEnumField) { |
|
| 85 | + $widget = $W->Select(); |
|
| 86 | + $widget->addOption('', ''); |
|
| 87 | + foreach ($field->getValues() as $key => $text) { |
|
| 88 | + $widget->addOption($key, $text); |
|
| 89 | + } |
|
| 90 | + } else if ($field instanceof ORMIntField) { |
|
| 91 | + $widget = $W->LineEdit()->setSize(9); |
|
| 92 | + } else if ($field instanceof ORMTextField) { |
|
| 93 | + $widget = $W->TextEdit()->setColumns(80)->setLines(5); |
|
| 94 | + } else if ($field instanceof ORMRecordSet) { |
|
| 95 | + $widget = app_genericSetEditor($field); |
|
| 96 | + $widget->addClass('sub-form'); |
|
| 97 | + } else { |
|
| 98 | + $widget = null; |
|
| 99 | + } |
|
| 100 | + if (isset($widget)) { |
|
| 101 | + $layout->addItem($W->VBoxLayout()->addItem($fieldLabel)->addItem($widget)); |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + return $layout; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | |
@@ -115,50 +115,50 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | function app_genericSetFilterForm(ORMRecordSet $set) |
| 117 | 117 | { |
| 118 | - $O = \bab_functionality::get('LibOrm'); |
|
| 119 | - $O->init(); |
|
| 120 | - $W = \bab_Widgets(); |
|
| 121 | - $layout = $W->FlowLayout(); |
|
| 122 | - $layout->setVerticalSpacing(1, 'em')->setHorizontalSpacing(1, 'em'); |
|
| 123 | - |
|
| 124 | - |
|
| 125 | - $fields = $set->getFields(); |
|
| 126 | - |
|
| 127 | - foreach ($fields as $field) { |
|
| 128 | - $description = $field->getDescription(); |
|
| 129 | - if (empty($description)) { |
|
| 130 | - $description = $field->getName(); |
|
| 131 | - } |
|
| 132 | - $fieldLabel = $W->Label($description . ':'); |
|
| 133 | - |
|
| 134 | - if ($field instanceof ORMDateField) { |
|
| 135 | - $widget = $W->PeriodPicker(); |
|
| 136 | - } else if ($field instanceof ORMTimeField) { |
|
| 137 | - $widget = $W->TimePicker(); |
|
| 138 | - } else if ($field instanceof ORMStringField) { |
|
| 139 | - $widget = $W->LineEdit()->setSize(min(array(15, $field->getMaxLength()))); |
|
| 140 | - } else if ($field instanceof ORMEnumField) { |
|
| 141 | - $widget = $W->Select(); |
|
| 142 | - $widget->addOption('', ''); |
|
| 143 | - foreach ($field->getValues() as $key => $text) { |
|
| 144 | - $widget->addOption($key, $text); |
|
| 145 | - } |
|
| 146 | - } else if ($field instanceof ORMIntField) { |
|
| 147 | - $widget = $W->LineEdit()->setSize(9); |
|
| 148 | - } else if ($field instanceof ORMTextField) { |
|
| 149 | - $widget = $widget = $W->LineEdit()->setSize(15); |
|
| 150 | - } else if ($field instanceof ORMRecordSet) { |
|
| 151 | - $widget = app_genericSetFilterForm($field); |
|
| 152 | - $widget->addClass('sub-form'); |
|
| 153 | - } else { |
|
| 154 | - $widget = null; |
|
| 155 | - } |
|
| 156 | - if (isset($widget)) { |
|
| 157 | - $layout->addItem($W->VBoxLayout()->addItem($fieldLabel)->addItem($widget)); |
|
| 158 | - } |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - return $layout; |
|
| 118 | + $O = \bab_functionality::get('LibOrm'); |
|
| 119 | + $O->init(); |
|
| 120 | + $W = \bab_Widgets(); |
|
| 121 | + $layout = $W->FlowLayout(); |
|
| 122 | + $layout->setVerticalSpacing(1, 'em')->setHorizontalSpacing(1, 'em'); |
|
| 123 | + |
|
| 124 | + |
|
| 125 | + $fields = $set->getFields(); |
|
| 126 | + |
|
| 127 | + foreach ($fields as $field) { |
|
| 128 | + $description = $field->getDescription(); |
|
| 129 | + if (empty($description)) { |
|
| 130 | + $description = $field->getName(); |
|
| 131 | + } |
|
| 132 | + $fieldLabel = $W->Label($description . ':'); |
|
| 133 | + |
|
| 134 | + if ($field instanceof ORMDateField) { |
|
| 135 | + $widget = $W->PeriodPicker(); |
|
| 136 | + } else if ($field instanceof ORMTimeField) { |
|
| 137 | + $widget = $W->TimePicker(); |
|
| 138 | + } else if ($field instanceof ORMStringField) { |
|
| 139 | + $widget = $W->LineEdit()->setSize(min(array(15, $field->getMaxLength()))); |
|
| 140 | + } else if ($field instanceof ORMEnumField) { |
|
| 141 | + $widget = $W->Select(); |
|
| 142 | + $widget->addOption('', ''); |
|
| 143 | + foreach ($field->getValues() as $key => $text) { |
|
| 144 | + $widget->addOption($key, $text); |
|
| 145 | + } |
|
| 146 | + } else if ($field instanceof ORMIntField) { |
|
| 147 | + $widget = $W->LineEdit()->setSize(9); |
|
| 148 | + } else if ($field instanceof ORMTextField) { |
|
| 149 | + $widget = $widget = $W->LineEdit()->setSize(15); |
|
| 150 | + } else if ($field instanceof ORMRecordSet) { |
|
| 151 | + $widget = app_genericSetFilterForm($field); |
|
| 152 | + $widget->addClass('sub-form'); |
|
| 153 | + } else { |
|
| 154 | + $widget = null; |
|
| 155 | + } |
|
| 156 | + if (isset($widget)) { |
|
| 157 | + $layout->addItem($W->VBoxLayout()->addItem($fieldLabel)->addItem($widget)); |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + return $layout; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | |
@@ -171,47 +171,47 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | function app_LabelledWidget($labelText, WidgetDisplayableInterface $widget) |
| 173 | 173 | { |
| 174 | - $W = \bab_Widgets(); |
|
| 175 | - |
|
| 176 | - $label = $W->Label($labelText); |
|
| 177 | - if ($widget instanceof WidgetInputWidget) { |
|
| 178 | - $label->setAssociatedWidget($widget); |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - if ($widget instanceof WidgetCheckBox) { |
|
| 182 | - $layout = $W->HBoxItems( |
|
| 183 | - $widget->setSizePolicy(WidgetSizePolicy::MINIMUM), |
|
| 184 | - $label |
|
| 185 | - )->setVerticalAlign('middle')->setHorizontalSpacing(0.5, 'em'); |
|
| 186 | - } else { |
|
| 187 | - $layout = $W->VBoxItems( |
|
| 188 | - $label, |
|
| 189 | - $widget |
|
| 190 | - )->setVerticalSpacing(0.5, 'em'); |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - return $layout; |
|
| 174 | + $W = \bab_Widgets(); |
|
| 175 | + |
|
| 176 | + $label = $W->Label($labelText); |
|
| 177 | + if ($widget instanceof WidgetInputWidget) { |
|
| 178 | + $label->setAssociatedWidget($widget); |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + if ($widget instanceof WidgetCheckBox) { |
|
| 182 | + $layout = $W->HBoxItems( |
|
| 183 | + $widget->setSizePolicy(WidgetSizePolicy::MINIMUM), |
|
| 184 | + $label |
|
| 185 | + )->setVerticalAlign('middle')->setHorizontalSpacing(0.5, 'em'); |
|
| 186 | + } else { |
|
| 187 | + $layout = $W->VBoxItems( |
|
| 188 | + $label, |
|
| 189 | + $widget |
|
| 190 | + )->setVerticalSpacing(0.5, 'em'); |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + return $layout; |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | |
| 197 | 197 | |
| 198 | 198 | function app_LabelledCheckbox($labelText, $checkboxName, $options = null) |
| 199 | 199 | { |
| 200 | - $W = \bab_Widgets(); |
|
| 200 | + $W = \bab_Widgets(); |
|
| 201 | 201 | |
| 202 | - $label = $W->Label($labelText)->colon(false); |
|
| 203 | - $checkbox = $W->Checkbox()->setName($checkboxName); |
|
| 204 | - $label->setAssociatedWidget($checkbox); |
|
| 205 | - if (isset($options)) { |
|
| 206 | - $label->setSizePolicy(WidgetSizePolicy::FIXED)->setCanvasOptions($options); |
|
| 207 | - } |
|
| 202 | + $label = $W->Label($labelText)->colon(false); |
|
| 203 | + $checkbox = $W->Checkbox()->setName($checkboxName); |
|
| 204 | + $label->setAssociatedWidget($checkbox); |
|
| 205 | + if (isset($options)) { |
|
| 206 | + $label->setSizePolicy(WidgetSizePolicy::FIXED)->setCanvasOptions($options); |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - $layout = $W->HBoxItems( |
|
| 210 | - $checkbox->setSizePolicy(WidgetSizePolicy::MINIMUM), |
|
| 211 | - $label |
|
| 212 | - )->setVerticalAlign('middle')->setHorizontalSpacing(0.5, 'em'); |
|
| 209 | + $layout = $W->HBoxItems( |
|
| 210 | + $checkbox->setSizePolicy(WidgetSizePolicy::MINIMUM), |
|
| 211 | + $label |
|
| 212 | + )->setVerticalAlign('middle')->setHorizontalSpacing(0.5, 'em'); |
|
| 213 | 213 | |
| 214 | - return $layout; |
|
| 214 | + return $layout; |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | |
@@ -219,42 +219,42 @@ discard block |
||
| 219 | 219 | |
| 220 | 220 | function app_LabelledOrmSelect(ORMMySqlIterator $iterator, $fieldName, $selectName, $label, $hidden = false, $groupFieldName = null) |
| 221 | 221 | { |
| 222 | - $W = \bab_Widgets(); |
|
| 223 | - |
|
| 224 | - if (isset($groupFieldName)) { |
|
| 225 | - $groupPathElements = explode('/', $groupFieldName); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - $select = $W->Select()->setName($selectName); |
|
| 229 | - |
|
| 230 | - $select->addOption('', ''); |
|
| 231 | - |
|
| 232 | - $nbOptions = 0; |
|
| 233 | - foreach ($iterator as $record) { |
|
| 234 | - if (isset($record->code)) { |
|
| 235 | - $optionText = $record->code . ' - ' . $record->$fieldName; |
|
| 236 | - } else { |
|
| 237 | - $optionText = $record->$fieldName; |
|
| 238 | - } |
|
| 239 | - if (isset($groupFieldName)) { |
|
| 240 | - $group = $record; |
|
| 241 | - foreach ($groupPathElements as $groupPathElement) { |
|
| 242 | - $group = $group->$groupPathElement; |
|
| 243 | - } |
|
| 244 | - $select->addOption($record->id, $optionText, $group); |
|
| 245 | - } else { |
|
| 246 | - $select->addOption($record->id, $optionText); |
|
| 247 | - } |
|
| 248 | - $nbOptions++; |
|
| 249 | - $lastId = $record->id; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - if ($nbOptions == 1) { |
|
| 253 | - $select->setValue($lastId); |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - |
|
| 257 | - return app_LabelledWidget($label, $select); |
|
| 222 | + $W = \bab_Widgets(); |
|
| 223 | + |
|
| 224 | + if (isset($groupFieldName)) { |
|
| 225 | + $groupPathElements = explode('/', $groupFieldName); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + $select = $W->Select()->setName($selectName); |
|
| 229 | + |
|
| 230 | + $select->addOption('', ''); |
|
| 231 | + |
|
| 232 | + $nbOptions = 0; |
|
| 233 | + foreach ($iterator as $record) { |
|
| 234 | + if (isset($record->code)) { |
|
| 235 | + $optionText = $record->code . ' - ' . $record->$fieldName; |
|
| 236 | + } else { |
|
| 237 | + $optionText = $record->$fieldName; |
|
| 238 | + } |
|
| 239 | + if (isset($groupFieldName)) { |
|
| 240 | + $group = $record; |
|
| 241 | + foreach ($groupPathElements as $groupPathElement) { |
|
| 242 | + $group = $group->$groupPathElement; |
|
| 243 | + } |
|
| 244 | + $select->addOption($record->id, $optionText, $group); |
|
| 245 | + } else { |
|
| 246 | + $select->addOption($record->id, $optionText); |
|
| 247 | + } |
|
| 248 | + $nbOptions++; |
|
| 249 | + $lastId = $record->id; |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + if ($nbOptions == 1) { |
|
| 253 | + $select->setValue($lastId); |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + |
|
| 257 | + return app_LabelledWidget($label, $select); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | |
@@ -302,36 +302,36 @@ discard block |
||
| 302 | 302 | ->setMaxSize($field->getMaxLength()); |
| 303 | 303 | } else if ($field instanceof ORMTextField) { |
| 304 | 304 | $widget = $W->TextEdit() |
| 305 | - ->addClass('widget-autoresize'); |
|
| 305 | + ->addClass('widget-autoresize'); |
|
| 306 | 306 | } else if ($field instanceof ORMPkField) { |
| 307 | 307 | $widget = $W->Hidden(); |
| 308 | 308 | } else if ($field instanceof ORMFkField) { |
| 309 | 309 | |
| 310 | 310 | $fieldName = $field->getName(); |
| 311 | 311 | /** @var AppRecordSet $parentSet */ |
| 312 | - $parentSet = clone $field->getParentSet(); |
|
| 312 | + $parentSet = clone $field->getParentSet(); |
|
| 313 | 313 | $parentSet->join($fieldName); |
| 314 | 314 | $set = $parentSet->$fieldName; |
| 315 | 315 | $records = $set->select(); |
| 316 | - $pkName = $set->getPrimaryKey(); |
|
| 317 | - if($set->fieldExist("name")){ |
|
| 318 | - $displayField = $set->name->getName(); |
|
| 319 | - }else if(method_exists($set,"getDisplayNameField")){ |
|
| 320 | - $displayField = $set->getDisplayNameField()->getName(); |
|
| 321 | - }else{ |
|
| 322 | - $displayField = $pkName; |
|
| 323 | - } |
|
| 324 | - $records->orderAsc($set->$displayField); |
|
| 325 | - if($records->count() > 50){ |
|
| 326 | - $widget = bab_Widgets()->select2(); |
|
| 327 | - $widget->setDataSource($set->getController()->search()); |
|
| 328 | - }else{ |
|
| 329 | - $widget = $W->Select(); |
|
| 330 | - $widget->addOption('', ''); |
|
| 331 | - foreach ($records as $record) { |
|
| 332 | - $widget->addOption($record->$pkName, $record->$displayField); |
|
| 333 | - } |
|
| 334 | - } |
|
| 316 | + $pkName = $set->getPrimaryKey(); |
|
| 317 | + if($set->fieldExist("name")){ |
|
| 318 | + $displayField = $set->name->getName(); |
|
| 319 | + }else if(method_exists($set,"getDisplayNameField")){ |
|
| 320 | + $displayField = $set->getDisplayNameField()->getName(); |
|
| 321 | + }else{ |
|
| 322 | + $displayField = $pkName; |
|
| 323 | + } |
|
| 324 | + $records->orderAsc($set->$displayField); |
|
| 325 | + if($records->count() > 50){ |
|
| 326 | + $widget = bab_Widgets()->select2(); |
|
| 327 | + $widget->setDataSource($set->getController()->search()); |
|
| 328 | + }else{ |
|
| 329 | + $widget = $W->Select(); |
|
| 330 | + $widget->addOption('', ''); |
|
| 331 | + foreach ($records as $record) { |
|
| 332 | + $widget->addOption($record->$pkName, $record->$displayField); |
|
| 333 | + } |
|
| 334 | + } |
|
| 335 | 335 | } else if ($field instanceof ORMRecordSet) { |
| 336 | 336 | $widget = $W->Select(); |
| 337 | 337 | //// $widget = $W->MultiSelect()->setSingleSelect(); |
@@ -357,21 +357,21 @@ discard block |
||
| 357 | 357 | |
| 358 | 358 | function app_LabelledOrmWidget(ORMField $field, $label = null, $hidden = false) |
| 359 | 359 | { |
| 360 | - $W = \bab_Widgets(); |
|
| 360 | + $W = \bab_Widgets(); |
|
| 361 | 361 | |
| 362 | - if ($hidden) { |
|
| 363 | - $widget = $W->Hidden(); |
|
| 364 | - $widget->setName($field->getName()); |
|
| 365 | - return $widget; |
|
| 366 | - } |
|
| 362 | + if ($hidden) { |
|
| 363 | + $widget = $W->Hidden(); |
|
| 364 | + $widget->setName($field->getName()); |
|
| 365 | + return $widget; |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | - if (is_null($label)) { |
|
| 369 | - $label = $field->getDescription(); |
|
| 370 | - } |
|
| 368 | + if (is_null($label)) { |
|
| 369 | + $label = $field->getDescription(); |
|
| 370 | + } |
|
| 371 | 371 | |
| 372 | - $widget = app_OrmWidget($field); |
|
| 372 | + $widget = app_OrmWidget($field); |
|
| 373 | 373 | |
| 374 | - return app_LabelledWidget($label, $widget); |
|
| 374 | + return app_LabelledWidget($label, $widget); |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | |
@@ -387,16 +387,16 @@ discard block |
||
| 387 | 387 | */ |
| 388 | 388 | function app_dateTime(ORMField $field, $value) { |
| 389 | 389 | |
| 390 | - $W = \bab_functionality::get('Widgets'); |
|
| 391 | - $name = $field->getName(); |
|
| 392 | - $label = $W->Label($field->getDescription()); |
|
| 390 | + $W = \bab_functionality::get('Widgets'); |
|
| 391 | + $name = $field->getName(); |
|
| 392 | + $label = $W->Label($field->getDescription()); |
|
| 393 | 393 | |
| 394 | - $frame = app_dateTimeField($name, $label, $value); |
|
| 394 | + $frame = app_dateTimeField($name, $label, $value); |
|
| 395 | 395 | |
| 396 | - return $W->VBoxItems( |
|
| 397 | - $label, |
|
| 398 | - $frame |
|
| 399 | - ); |
|
| 396 | + return $W->VBoxItems( |
|
| 397 | + $label, |
|
| 398 | + $frame |
|
| 399 | + ); |
|
| 400 | 400 | |
| 401 | 401 | } |
| 402 | 402 | |
@@ -410,24 +410,24 @@ discard block |
||
| 410 | 410 | */ |
| 411 | 411 | function app_dateTimeField($fieldName, WidgetLabel $label, $value = null) |
| 412 | 412 | { |
| 413 | - $W = \bab_functionality::get('Widgets'); |
|
| 413 | + $W = \bab_functionality::get('Widgets'); |
|
| 414 | 414 | |
| 415 | - $datepart = $W->DatePicker()->setAssociatedLabel($label)->setName('date'); |
|
| 416 | - $timepart = $W->TimePicker()->setName('time'); |
|
| 415 | + $datepart = $W->DatePicker()->setAssociatedLabel($label)->setName('date'); |
|
| 416 | + $timepart = $W->TimePicker()->setName('time'); |
|
| 417 | 417 | |
| 418 | - if (isset($value)) { |
|
| 418 | + if (isset($value)) { |
|
| 419 | 419 | |
| 420 | - $value = explode(' ', $value); |
|
| 420 | + $value = explode(' ', $value); |
|
| 421 | 421 | |
| 422 | - $datepart->setValue($value[0]); |
|
| 423 | - $timepart->setValue($value[1]); |
|
| 424 | - } |
|
| 422 | + $datepart->setValue($value[0]); |
|
| 423 | + $timepart->setValue($value[1]); |
|
| 424 | + } |
|
| 425 | 425 | |
| 426 | - $datetime = $W->Frame(null, $W->HBoxLayout())->setName($fieldName) |
|
| 427 | - ->addItem($datepart) |
|
| 428 | - ->addItem($timepart); |
|
| 426 | + $datetime = $W->Frame(null, $W->HBoxLayout())->setName($fieldName) |
|
| 427 | + ->addItem($datepart) |
|
| 428 | + ->addItem($timepart); |
|
| 429 | 429 | |
| 430 | - return $datetime; |
|
| 430 | + return $datetime; |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | |
@@ -316,16 +316,16 @@ |
||
| 316 | 316 | $pkName = $set->getPrimaryKey(); |
| 317 | 317 | if($set->fieldExist("name")){ |
| 318 | 318 | $displayField = $set->name->getName(); |
| 319 | - }else if(method_exists($set,"getDisplayNameField")){ |
|
| 319 | + } else if(method_exists($set,"getDisplayNameField")){ |
|
| 320 | 320 | $displayField = $set->getDisplayNameField()->getName(); |
| 321 | - }else{ |
|
| 321 | + } else{ |
|
| 322 | 322 | $displayField = $pkName; |
| 323 | 323 | } |
| 324 | 324 | $records->orderAsc($set->$displayField); |
| 325 | 325 | if($records->count() > 50){ |
| 326 | 326 | $widget = bab_Widgets()->select2(); |
| 327 | 327 | $widget->setDataSource($set->getController()->search()); |
| 328 | - }else{ |
|
| 328 | + } else{ |
|
| 329 | 329 | $widget = $W->Select(); |
| 330 | 330 | $widget->addOption('', ''); |
| 331 | 331 | foreach ($records as $record) { |
@@ -140,16 +140,14 @@ discard block |
||
| 140 | 140 | $isSearchable = false; |
| 141 | 141 | $isSortable = false; |
| 142 | 142 | $columnItem = $W->FlexItems($this->toggleCheckAllBox); |
| 143 | - } |
|
| 144 | - elseif(isset($this->sortParameterName) && self::getRecordSetField($set, $columnPath) && $isSortable){ |
|
| 143 | + } elseif(isset($this->sortParameterName) && self::getRecordSetField($set, $columnPath) && $isSortable){ |
|
| 145 | 144 | if(! isset($this->sortBaseUrl)){ |
| 146 | 145 | $this->sortBaseUrl = \bab_url::request_gp(); |
| 147 | 146 | } |
| 148 | 147 | |
| 149 | 148 | if($this->sortField === $columnPath && $this->sortAscending){ |
| 150 | 149 | $direction = ':down'; |
| 151 | - } |
|
| 152 | - else{ |
|
| 150 | + } else{ |
|
| 153 | 151 | $direction = ':up'; |
| 154 | 152 | } |
| 155 | 153 | |
@@ -166,8 +164,7 @@ discard block |
||
| 166 | 164 | $columnItem->setAjaxAction($this->sortAjaxAction->setParameter('sort', $columnPath . $direction), ''); |
| 167 | 165 | } |
| 168 | 166 | $columnItem = $W->FlexItems($columnItem); |
| 169 | - } |
|
| 170 | - else{ |
|
| 167 | + } else{ |
|
| 171 | 168 | $columnItem = $W->FlexItems($W->Label($columnLabel), $W->Label('')); |
| 172 | 169 | } |
| 173 | 170 | |
@@ -299,20 +296,17 @@ discard block |
||
| 299 | 296 | |
| 300 | 297 | if(isset($name)){ |
| 301 | 298 | $this->sortParameterName = $name . '[filter][sort]'; |
| 302 | - } |
|
| 303 | - else{ |
|
| 299 | + } else{ |
|
| 304 | 300 | $this->sortParameterName = 'filter[sort]'; |
| 305 | 301 | } |
| 306 | 302 | |
| 307 | 303 | if(isset($filter['sort'])){ |
| 308 | 304 | $this->setSortField($filter['sort']); |
| 309 | - } |
|
| 310 | - elseif(! isset($this->sortField)){ |
|
| 305 | + } elseif(! isset($this->sortField)){ |
|
| 311 | 306 | |
| 312 | 307 | if(method_exists($this, 'getDefaultSortField')){ |
| 313 | 308 | $this->setSortField($this->getDefaultSortField()); |
| 314 | - } |
|
| 315 | - else{ |
|
| 309 | + } else{ |
|
| 316 | 310 | $columns = $this->getVisibleColumns(); |
| 317 | 311 | $sortField = key($columns); |
| 318 | 312 | $this->setSortField($sortField); |
@@ -327,8 +321,7 @@ discard block |
||
| 327 | 321 | $name, |
| 328 | 322 | 'filter' |
| 329 | 323 | ); |
| 330 | - } |
|
| 331 | - else{ |
|
| 324 | + } else{ |
|
| 332 | 325 | $path = array( |
| 333 | 326 | 'filter' |
| 334 | 327 | ); |
@@ -389,8 +382,7 @@ discard block |
||
| 389 | 382 | $pos = strrpos($setName, '\\'); |
| 390 | 383 | if($pos === false){ |
| 391 | 384 | list (, $appSetName) = explode('_', $setName); |
| 392 | - } |
|
| 393 | - else{ |
|
| 385 | + } else{ |
|
| 394 | 386 | list (, $appSetName) = array( |
| 395 | 387 | substr($setName, 0, $pos), |
| 396 | 388 | substr($setName, $pos + 1) |
@@ -409,7 +401,7 @@ discard block |
||
| 409 | 401 | if($values->count()>15){ |
| 410 | 402 | $widget = bab_Widgets()->select2(); |
| 411 | 403 | $widget->setDataSource($set->getController()->search()); |
| 412 | - }else{ |
|
| 404 | + } else{ |
|
| 413 | 405 | $widget = $W->Select(); |
| 414 | 406 | $widget->addOption('', ''); |
| 415 | 407 | foreach ($values as $record){ |
@@ -549,8 +541,7 @@ discard block |
||
| 549 | 541 | ->addClass('icon', \Func_Icons::STATUS_DIALOG_ERROR) |
| 550 | 542 | ->addAttribute('data-removefor', $column->getFieldPath())) |
| 551 | 543 | ->setAlignItems(WidgetFlexLayout::FLEX_ALIGN_ITEMS_FLEX_END)); |
| 552 | - } |
|
| 553 | - elseif($displayAdvancedForm){ |
|
| 544 | + } elseif($displayAdvancedForm){ |
|
| 554 | 545 | $formItem->setSizePolicy('col-lg-2 col-md-3 col-sm-6 col-xs-12'); |
| 555 | 546 | $filterBox->addItem($formItem); |
| 556 | 547 | } |
@@ -683,20 +674,17 @@ discard block |
||
| 683 | 674 | |
| 684 | 675 | if(isset($name)){ |
| 685 | 676 | $this->sortParameterName = $name . '[filter][sort]'; |
| 686 | - } |
|
| 687 | - else{ |
|
| 677 | + } else{ |
|
| 688 | 678 | $this->sortParameterName = 'filter[sort]'; |
| 689 | 679 | } |
| 690 | 680 | |
| 691 | 681 | if(isset($filter['sort'])){ |
| 692 | 682 | $this->setSortField($filter['sort']); |
| 693 | - } |
|
| 694 | - elseif(! isset($this->sortField)){ |
|
| 683 | + } elseif(! isset($this->sortField)){ |
|
| 695 | 684 | |
| 696 | 685 | if(method_exists($this, 'getDefaultSortField')){ |
| 697 | 686 | $this->setSortField($this->getDefaultSortField()); |
| 698 | - } |
|
| 699 | - else{ |
|
| 687 | + } else{ |
|
| 700 | 688 | $columns = $this->getVisibleColumns(); |
| 701 | 689 | $sortField = key($columns); |
| 702 | 690 | $this->setSortField($sortField); |
@@ -711,8 +699,7 @@ discard block |
||
| 711 | 699 | $name, |
| 712 | 700 | 'filter' |
| 713 | 701 | ); |
| 714 | - } |
|
| 715 | - else{ |
|
| 702 | + } else{ |
|
| 716 | 703 | $path = array( |
| 717 | 704 | 'filter' |
| 718 | 705 | ); |