public function ajaxListAction() { $fields = array('id', 'menuStoreId', 'action', 'quantity', 'unit', 'date', 'note', 'cost', 'supplier', 'store', 'orderId'); $offset = $this->getDataTableQueryOffset(); $limit = $this->getDataTableQueryLimit(); $sortCol = $this->getDataTableQuerySortingColumn(); $sortDirection = $this->getDataTableQuerySortingDirection(); $search = $this->getDataTableQuerySearch(); // WHERE conditions $dqlWhere = $this->getDataTableWhereDql('c', $fields, $search); // ORDERING $dqlOrder = $this->getDataTableOrderDql('c', $fields, $sortCol, $sortDirection); // DQL $dql = "SELECT c FROM Admin\\Entity\\Transaction c"; // RESULTS $query = $this->getEntityManager()->createQuery($dql . $dqlWhere . $dqlOrder); if (!empty($dqlWhere)) { $query->setParameter(':search', '%' . $search . '%'); } $results = $query->setMaxResults($limit)->setFirstResult($offset)->getResult(); // TOTAL RESULTS COUNT $countDql = "SELECT COUNT(c.id) FROM Admin\\Entity\\Transaction c "; $count = $this->getEntityManager()->createQuery($countDql)->getSingleScalarResult(); // map data $ret = array_map(function ($item) { $storeInfo = Utility::getMainStoreInfo($item->getMenuStoreId()); // create link $linkEdit = '/admin/transaction/add/' . $item->getId(); $linkDelete = '/admin/transaction/delete/' . $item->getId(); $linkDetail = '/admin/transaction/detail/' . $item->getId(); return array('id' => $item->getId(), 'menuStoreId' => $storeInfo->getName(), 'action' => $item->getAction(), 'quantity' => $item->getQuantity(), 'unit' => $item->getUnit(), 'date' => $item->getDate(), 'note' => $item->getNote(), 'cost' => $item->getCost(), 'supplier' => $item->getSupplier(), 'store' => $item->getStore(), 'orderId' => $item->getOrderId(), 'actions' => '<a href="' . $linkDetail . '" class="btn btn-info"><i class="icon-edit-sign"></i></a><a class="btn btn-primary" href="' . $linkEdit . '"><i class="icon-edit-sign"></i></a><a href="' . $linkDelete . '" class="btn btn-danger"><i class="icon-trash"></i></a>'); }, $results); return $this->getDataTableJsonResponse($ret, $count, $dqlWhere); }
public function convertToArray($datas, $store = SUB_STORE) { $return = array(); foreach ($datas as $data) { $storeInfo = Utility::getStoreInfo($data->getMenuStoreId()); if ($store == MAIN_STORE) { $storeInfo = Utility::getMainStoreInfo($data->getMenuStoreId()); } $note = TransactionUtility::getStoreItemInOrder($data->getNote()); if ($note == '') { $note = $data->getNote(); } $supplier = Utility::getSupplierInfo($data->getSupplier()); $array = array(); $array['id'] = $data->getId(); $array['menuStoreId'] = $storeInfo->getName(); $array['action'] = $data->getAction(); $array['quantity'] = $data->getQuantity(); $array['unit'] = $data->getUnit(); $array['date'] = date('d-m-Y', $data->getDate()); $array['note'] = $note; $array['cost'] = $data->getCost(); $array['supplier'] = $supplier->getCompanyName(); $return[] = $array; } return $return; }
public function managerInOutAction() { $columns = array(array('title' => 'Id', 'db' => 'id', 'dt' => 0, 'select' => 'id', 'prefix' => 'o', 'search' => false, 'type' => 'number'), array('title' => 'Store Name', 'db' => 'menuStoreId', 'dt' => 1, 'select' => 'menuStoreId', 'prefix' => 'o', 'search' => true, 'type' => 'text', 'formatter' => function ($d, $row) { $storeInfo = Utility::getMainStoreInfo($d); return $storeInfo->getName(); }), array('title' => 'Action', 'db' => 'action', 'dt' => 2, 'select' => 'action', 'prefix' => 'o', 'search' => true, 'type' => 'text'), array('title' => 'Quantity', 'db' => 'quantity', 'dt' => 3, 'select' => 'quantity', 'prefix' => 'o', 'search' => true, 'type' => 'text'), array('title' => 'Cost', 'db' => 'cost', 'dt' => 4, 'select' => 'cost', 'prefix' => 'o', 'search' => true, 'type' => 'text'), array('title' => 'Note', 'db' => 'note', 'dt' => 5, 'select' => 'note', 'prefix' => 'o', 'search' => true, 'type' => 'text', 'formatter' => function ($d, $row) { $note = TransactionUtility::getStoreItemInOrder($d); if ($note == '') { $note = $d; } return $note; }), array('title' => 'Action', 'db' => 'orderId', 'dt' => 6, 'select' => 'id', 'prefix' => 'o', 'search' => false, 'type' => 'number', 'formatter' => function ($d, $row) { $actionUrl = '/admin/menustoremain'; return ' <a class="btn-xs action action-detail btn btn-info btn-default" href="' . $actionUrl . '/detail/' . $d . '"><i class="icon-info-sign"></i></a> <a class="btn-xs action action-detail btn btn-success btn-default" href="' . $actionUrl . '/add/' . $d . '"><i class="icon-edit"></i></a> <a data-id="' . $d . '" id="' . $d . '" data-link="' . $actionUrl . '" class="btn-xs action action-detail btn btn-danger btn-delete " href="javascript:void(0)"><i class="icon-remove"></i></a> '; })); /////end column for table $table = new AjaxTable(array(), array(), 'admin/menustoremain/managerinout'); $table->setTableColumns($columns); $table->setTablePrefix('o'); $table->setAjaxCall('/admin/menustoremain/managerinout'); $table->setActionDeleteAll('deleteall'); $this->tableAjaxRequest($table, $columns, $this->transactionModel); return new ViewModel(array('table' => $table, 'title' => $this->translator->translate('Manage Import/Export'))); }