public function convertSingleToArray($coupon) { $translator = Utility::translate(); $couponType = Utility::getCouponType($coupon->getType()); $array = array(); $array['id'] = $coupon->getId(); $array['code'] = $coupon->getCode(); $array['value'] = $coupon->getValue(); $array['fromdate'] = date('d/m/Y', $coupon->getFromDate()); $array['todate'] = date('d/m/Y', $coupon->getToDate()); $array['type'] = $translator->translate($couponType); $array['description'] = $coupon->getDescription(); return $array; }
public function indexAction() { //config table /////column for table $columns = array(array('title' => 'Id', 'db' => 'id', 'dt' => 0, 'search' => false, 'type' => 'number'), array('title' => 'Code', 'db' => 'code', 'dt' => 1, 'search' => true, 'type' => 'text'), array('title' => 'Value', 'db' => 'value', 'dt' => 2, 'search' => true, 'type' => 'text'), array('title' => 'Type', 'db' => 'type', 'dt' => 3, 'search' => true, 'type' => 'text', 'dataSelect' => Utility::getCouponType()), array('title' => 'From Date', 'db' => 'fromdate', 'dt' => 4, 'search' => true, 'type' => 'text'), array('title' => 'To Date', 'db' => 'todate', 'dt' => 5, 'search' => true, 'type' => 'text'), array('title' => 'Action', 'db' => 'id', 'dt' => 6, 'search' => false, 'type' => 'number', 'formatter' => function ($d, $row) { $actionUrl = '/admin/coupon'; return ' <a class="btn-xs action action-detail btn btn-success btn-default" href="' . $actionUrl . '/add/' . $d . '"><i class="icon-edit"></i></a> <a class="btn-xs action action-detail btn btn-danger " href="' . $actionUrl . '/delete/' . $d . '"><i class="icon-remove"></i></a> '; })); /////end column for table $table = new AjaxTable($columns, array(), 'admin/coupon'); $table->setTablePrefix('m'); $table->setExtendSQl(array(array('AND', 'm.isdelete', '=', '0'))); $table->setAjaxCall('/admin/coupon'); $table->setActionDeleteAll('deleteall'); $this->tableAjaxRequest($table, $columns, $this->modelCoupon); //end config table return new ViewModel(array('table' => $table, 'title' => $this->translator->translate('Manage Coupon'))); }