Hallo zusammen,
Ich habe ein Problem mit CHTML und einem View. Im Controller hab ich zwei relevante Actions:
-
actionView zweigt eine Rechnung mit den dazugehörigen Rechnungsposten via relations an
-
actionAjaxView lädt beim umsortieren der Rechnungsposten die modifizierte Tabelle mit den Posten nach und Zeigt sie an.
Dafür hab ich zwei Views. Einemal die view.php die das Widget CDetailView anzeigt plus einen renderPartial der die Tabelle mit den Rechnungsposten anzeigt. Habe das extra ausgelagert damit ich, via Ajax auch nur das View mit den Rechnugnsposten nachladen muss. Das ganze sieht in etwa so aus:
actionLoadBillingItemsAjax($id, $item, $item2) {
//Vertausche beide Items
if ($item->save() and $item2->save()) {
$model = Billing::model()->with(array(
'billingItem' => array(
'order' => 'list_order ASC',
),
))->findByPk($id);
$this->renderPartial('billingItems', array(
'model'=>$model,
));
}
}
Die billingItems.php sieht so aus:
<?php
$i = 1;
foreach ($model->billingItem as $item)
{
$i++;
if ($i % 2 == 0) {
$class = "even";
}
else {
$class = "odd";
}
?>
<tr class="<?php echo $class ?>" id="billingItem<?php echo $item->id ?>">
<td class="text">
<?php
echo '<span class="title"><a href="' . $this->createUrl('BillingItems/update', array('id' => $item->id)) . '">' . CHTML::encode($item->title) . '</a></span><br /><span class="description">' . nl2br(CHTML::encode($item->description)) . '</span>';
?>
</td>
<td class="amount">
<?php
echo CHtml::encode($item->amount) . ' €';
?>
</td>
<td class="listOrder">
<?php if ($i > 2) { ?>
<?php echo CHtml::ajaxLink('<img src="' . Yii::app()->theme->baseUrl . '/images/general/arrowUp.png" />', array('Billing/LoadBillingItemsAjax', 'id' => $this->id, 'item' => $item->id, 'item2' => $model->billingItem[$i-3]->id), array('update' => "#billingItems"), array('class' => 'listOrder')); ?><br />
<?php
}
if ($i <= sizeof($model->billingItem)) {
echo CHtml::ajaxLink('<img src="' . Yii::app()->theme->baseUrl . '/images/general/arrowDown.png" />', array('Billing/LoadBillingItemsAjax', 'id' => $this->id, 'item' => $item->id, 'item2' => $model->billingItem[$i-1]->id), array('update'=>'#billingItems'), array('class' => 'listOrder')); ?>
<?php } ?>
</td>
</tr>
<?php
}
?>
Lange rede gar kein Sinn, das View funktioniert perfekt, das vertauschen auch, nur das nachladen via Ajax funktioniert nicht weil ein HTTP Fehler 500 erzeugt wird da die Datei CHTML.php nicht gefunden werden kann. Warum klappt es bei dem View, aber beim nachladen gibt es einen Fehler? Folgends bekomme ich mit Hilfe von Firebug angezeigt:
<h1>PHP Error [2]</h1>
<p>include(CHTML.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory (/Applications/XAMPP/xamppfiles/htdocs/crm/framework/YiiBase.php:421)</p>
<pre>#0 /Applications/XAMPP/xamppfiles/htdocs/crm/framework/YiiBase.php(421): CWebApplication->handleError()
#1 /Applications/XAMPP/xamppfiles/htdocs/crm/framework/YiiBase.php(421): autoload()
#2 unknown(0): autoload()
#3 /Applications/XAMPP/xamppfiles/htdocs/crm/themes/classic/views/billing/billingItems.php(17): spl_autoload_call()
#4 /Applications/XAMPP/xamppfiles/htdocs/crm/framework/web/CBaseController.php(119): require()
#5 /Applications/XAMPP/xamppfiles/htdocs/crm/framework/web/CBaseController.php(88): BillingController->renderInternal()
#6 /Applications/XAMPP/xamppfiles/htdocs/crm/framework/web/CController.php(866): BillingController->renderFile()
#7 /Applications/XAMPP/xamppfiles/htdocs/crm/framework/web/CController.php(779): BillingController->renderPartial()
#8 /Applications/XAMPP/xamppfiles/htdocs/crm/protected/controllers/BillingController.php(263): BillingController->render()
#9 unknown(0): BillingController->actionLoadBillingItemsAjax()
#10 /Applications/XAMPP/xamppfiles/htdocs/crm/framework/web/actions/CAction.php(104): ReflectionMethod->invokeArgs()
#11 /Applications/XAMPP/xamppfiles/htdocs/crm/framework/web/actions/CInlineAction.php(48): CInlineAction->runWithParamsInternal()
#12 /Applications/XAMPP/xamppfiles/htdocs/crm/framework/web/CController.php(300): CInlineAction->runWithParams()
#13 /Applications/XAMPP/xamppfiles/htdocs/crm/framework/web/filters/CFilterChain.php(134): BillingController->runAction()
#14 /Applications/XAMPP/xamppfiles/htdocs/crm/framework/web/filters/CFilter.php(41): CFilterChain->run()
#15 /Applications/XAMPP/xamppfiles/htdocs/crm/framework/web/CController.php(1144): CAccessControlFilter->filter()
#16 /Applications/XAMPP/xamppfiles/htdocs/crm/framework/web/filters/CInlineFilter.php(59): BillingController->filterAccessControl()
#17 /Applications/XAMPP/xamppfiles/htdocs/crm/framework/web/filters/CFilterChain.php(131): CInlineFilter->filter()
#18 /Applications/XAMPP/xamppfiles/htdocs/crm/framework/web/CController.php(283): CFilterChain->run()
#19 /Applications/XAMPP/xamppfiles/htdocs/crm/framework/web/CController.php(257): BillingController->runActionWithFilters()
#20 /Applications/XAMPP/xamppfiles/htdocs/crm/framework/web/CWebApplication.php(277): BillingController->run()
#21 /Applications/XAMPP/xamppfiles/htdocs/crm/framework/web/CWebApplication.php(136): CWebApplication->runController()
#22 /Applications/XAMPP/xamppfiles/htdocs/crm/framework/base/CApplication.php(158): CWebApplication->processRequest()
#23 /Applications/XAMPP/xamppfiles/htdocs/crm/index.php(13): CWebApplication->run()
</pre>
Vielen Dank