- 1
- 2
- 3
- 4
@old_article_purchase.old_article.warehouse_placement = '102A1'
if @old_article_purchase.old_article.valid?
@old_article_purchase.old_article.save
end
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Всего: 5
−82
@old_article_purchase.old_article.warehouse_placement = '102A1'
if @old_article_purchase.old_article.valid?
@old_article_purchase.old_article.save
end
−136
it 'traders email should be nil' do
trader = FactoryGirl.create(:trader, :email => nil)
trader.email.should be nil
end
captain obvious test
+165
echo str_repeat('<br />', 25);
Делаем правильные отступы
+162
<tbody>
<script type="application/json">
{
"remoteURL" : "/index.php?module=User&controller=Ajax_Group",
"saveState" : true,
"browseable":
{
"entriesTotal": {$amountGroups},
"entriesPage": {$itemsPerPage},
"activePage": {$activePage}
},
"columns":
{
"title":
{
"dataType": "string"
},
"description":
{
"dataType": "string"
}
},
"searchable":
{
"searchCols": [ "title", "description" ],
"activeSearch": "{addcslashes( $searchTerm, '"' )}",
"minSearchLength" : {$searchMinWordLength}
},
"sortable":
{
"sortCols": [ "title", "description" ],
"activeCol":
{
"column": "{$sortColumn}",
"sortDir" : "{$sortDirection}"
}
},
"clickable":
{
"defaultAction": [ "{Common_Image_Icon_Ajax::EDIT}" ]
}
}
</script>
{foreach $Groups as $Group}
{$group_id = $Group->getGroup_Id()}
<tr>
{if $rightToExport}
<td class="selector"><input type="checkbox" name="checkedGroups[]" value="{$group_id}"></td>
{/if}
<td>{$Group->escapeTitle()}</td>
<td>{$Group->escapeDescription()}</td>
{if $rightEdit || $rightDelete || $rightMail}
<td class="actions">
{Common_Image_Icon_Overlay::fetchIcon(Common_Image_Icon::EDIT, _( 'Edit' ), Common_Http_Query::fetch( ['module' => 'User', 'controller' => 'Overlay_Group', 'action' => 'edit', 'id' => $Group->getGroup_Id()] ))}
{if $rightDelete}
{$sql = "SELECT assessment_id FROM cobit_assessments WHERE usergroup_id = {$Group->getGroup_Id()} LIMIT 0,1"}
{$MySqlI = DatabaseConnector::getConnector()}
{$Result = $MySqlI->query( $sql )}
{if !( is_object( $Result ) and $Result->getNumRows() > 0 )}
{Common_Image_Icon_Ajax::fetchDelete( _( 'Delete' ), _( 'Do you really want to delete this Group?' ), Common_Http_Query::fetch( ['module' => 'User', 'controller' => 'Ajax_Group', 'action' => 'delete', 'id' => $Group->getGroup_Id()] ), $Group->getGroup_Id() )}
{else}
{Common_Image_Icon::fetchIcon(Common_Image_Icon::INFO, _("User Group is not deletable, because it is in use."))}
{/if}
{/if}
{if $rightMail}
{$sJavaScriptAction = Common_Event_Trigger_Overlay::fetch( Common_Event_Trigger_Overlay::OPEN, [ 'url' => "/index.php?module=User&controller=Overlay_Group&action=sendGroupMail&id={$Group->getGroup_Id()}"] )}
{Common_Image_Icon_Ajax::fetchIcon( Common_Image_Icon_Ajax::EMAIL, _('Send mail'), $sJavaScriptAction)}
{/if}
</td>
{/if}
</tr>
{/foreach}
</tbody>
Smarty Ajax SQL Table
Как все таки вставить SQL в Smarty.
+162
$sql = "SELECT aps.* FROM apps_applicationinterfaceincoming aps
WHERE aps.applicationid = '$id' ORDER BY aps.name ASC";
$Result = $Database->query( $sql );
foreach( $Result as $aResult )
{
$editIcon = Common_Image_Icon_Overlay::fetchIcon(
Common_Image_Icon_Overlay::EDIT, _('Edit interface' ),
'/apps/serveroverlay.php?table=apps_applicationinterfaceincoming&edit=1&mode='.AppsEnvironment::iVIEWMODE_EDIT.'&id='.$aResult['id']
);
$deleteIcon = Common_Image_Icon_Ajax::fetch(
Common_Image_Icon_Ajax::DELETE, array( 'aLinkAttributes' => array(
'onclick' => "new Browser.Http.Ajax.Updater( '#interfacein',
'/apps/interfacein_ajax.php?action=remove&id={$aResult['id']}' );" ) )
);
$html .= <<<EOF
<tr>
<td>{$aResult['name']}</td>
<td>{$aResult['frequency_data_transfers']}</td>
<td>{$aResult['type_of_interface']}</td>
<td>{$aResult['internal_external']}</td>
<td>{$aResult['description']}</td>
<td class="actions">{$editIcon} {$deleteIcon}</td>
</tr>
EOF;
}
$html .= <<<EOF
</tbody>
</table>
</fieldset>
EOF;
PHP Bestpractice php + sql + html + js in one file
или даэже in one String.
... 800 строк в том же духе. (толко в етом файле)