我是MVC的新手,它伤害了我的大脑。
我的观点如下:
<div class="uk-width-1">
<!--<a href="--><?php //echo Yii::app()->request->baseUrl; ?><!--/admin/userList/Do/Add" class="uk-button"><i class="fa fa-plus"></i> --><?php //echo Yii::t("default","Add New")?><!--</a>-->
<a href="<?php echo Yii::app()->request->baseUrl; ?>/admin/driverList" class="uk-button"><i class="fa fa-list"></i> <?php echo Yii::t("default","List")?></a>
</div>
<form id="frm_table_list" method="POST" >
<input type="hidden" name="action" id="action" value="AdminDriverList">
<input type="hidden" name="tbl" id="tbl" value="drivers">
<input type="hidden" name="clear_tbl" id="clear_tbl" value="clear_tbl">
<input type="hidden" name="whereid" id="whereid" value="id">
<input type="hidden" name="slug" id="slug" value="driverList">
<table id="table_list" class="uk-table uk-table-hover uk-table-striped uk-table-condensed">
<!--<caption>Merchant List</caption>-->
<thead>
<tr>
<th width="3%"><?php echo Yii::t("default","Driver ID")?></th>
<th width="5%"><?php echo Yii::t("default","Email")?></th>
<th width="3%"><?php echo Yii::t("default","Hourly Rate ($/hr)")?></th>
<th width="3%"><?php echo Yii::t("default","Minutes Worked")?></th>
<th width="3%"><?php echo Yii::t("default","Pay Owed ($)")?></th>
<th width="3%"><?php echo Yii::t("default","Amount Paid to Driver")?></th>
<th width="3%"><?php echo Yii::t("default","Confirm Payment")?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div class="clear"></div>
</form>
使用以下方法成功加载了正确的数据:
public function AdminDriverList()
{
$slug=Yii::app()->request->baseUrl."/admin/".$_GET['slug'];
$stmt="SELECT * FROM
{{drivers}}
ORDER BY id ASC
";
if ($res=$this->rst($stmt)){
foreach ($res as $val) {
$action="<div class=\"options\">
<a href=\"$slug/Do/Add/?id=$val[admin_id]\" >".Yii::t("default","Edit")."</a>
<a href=\"javascript:;\" class=\"row_del\" rev=\"$val[admin_id]\" >".Yii::t("default","Delete")."</a>
</div>";
/*$date=Yii::app()->functions->prettyDate($val['date_created']);
$date=Yii::app()->functions->translateDate($date); */
$feed_data['aaData'][]=array(
$val['id'],
$val['email'],
$val['hourly_rate'],
$val['minutes_worked'],
round($val['hourly_rate'] * $val["minutes_worked"] / 60, 2),
"<input type=\"number\" name=\"amount_paid_to_driver\" placeholder=\"Enter amount paid\" step=\"0.01\"/>",
"<button id='confirm_driver_payment'>Confirm Payment</button>"
);
}
$this->otableOutput($feed_data);
}
$this->otableNodata();
}
但我很难在“确认付款”按钮中添加其他操作。
但我不确定我是如何确认付款按钮,该按钮将成功从amount_paid_to_driver字段获取金额,并在正确的驱动程序ID下从名为mt_drivers的SQL数据库中减去它。
对新手的任何指导表示赞赏。
谢谢。