public function convertSingleToArray($data)
 {
     $array = array();
     $input = TransactionUtility::checkStore($data->getId(), INSERT_STORE_ACRION);
     if (isset($input[0])) {
         $input = $input[0]['sum_store'];
     } else {
         $input = 0;
     }
     $output = TransactionUtility::checkStore($data->getId(), ADD_ORDER_ACTION);
     if (isset($output[0])) {
         $output = $output[0]['sum_store'];
     } else {
         $output = 0;
     }
     $supplier = Utility::getSupplierInfo($data->getSupplier());
     $array['id'] = $data->getId();
     $array['name'] = $data->getName();
     $array['quantityInput'] = number_format($input);
     $array['quantityOutput'] = number_format($output);
     $array['quantityInStock'] = TransactionUtility::getMenuItemQuantityInStore($data->getId());
     $array['unit'] = $data->getUnit();
     $array['outOfStock'] = $data->getOutOfStock();
     $array['des'] = $data->getDes();
     $array['cost'] = $data->getCost();
     $array['supplier'] = $supplier->getCompanyName();
     $array['supplyType'] = $data->getSupplyItem();
     $array['InMenu'] = Utility::getMenuInMenuStore($data->getId());
     return $array;
 }
 public function indexAction()
 {
     $columns = array(array('title' => 'Id', 'db' => 'id', 'dt' => 0, 'search' => false, 'type' => 'number'), array('title' => 'Name', 'db' => 'name', 'dt' => 1, 'search' => true, 'type' => 'text'), array('title' => 'Cost', 'db' => 'cost', 'dt' => 2, 'search' => false, 'type' => 'number'), array('title' => 'In', 'db' => 'id', 'dt' => 3, 'search' => true, 'type' => 'number', 'formatter' => function ($d, $row) {
         $quantityInput = TransactionUtility::checkStore($d, INSERT_STORE_ACRION, MAIN_STORE);
         if (isset($quantityInput[0])) {
             $input = $quantityInput[0]['sum_store'];
         } else {
             $input = 0;
         }
         return $input;
     }), array('title' => 'Out', 'db' => 'id', 'dt' => 4, 'search' => true, 'type' => 'number', 'formatter' => function ($d, $row) {
         $quantityOut = TransactionUtility::checkStore($d, ADD_ORDER_ACTION, MAIN_STORE);
         if (isset($quantityOut[0])) {
             $output = $quantityOut[0]['sum_store'];
         } else {
             $output = 0;
         }
         return $output;
     }), array('title' => 'In Stock', 'db' => 'quantityInStock', 'dt' => 5, 'search' => false, 'type' => 'number'), array('title' => 'Unit', 'db' => 'unit', 'dt' => 6, 'search' => false, 'type' => 'text', 'formatter' => function ($d, $row) {
         $unitList = Utility::getUnitListForSelect();
         return $unitList[$d];
     }), array('title' => 'Supplier', 'db' => 'supplier', 'dt' => 7, 'search' => true, 'type' => 'text'), array('title' => 'Action', 'db' => 'id', 'dt' => 8, 'search' => false, 'type' => 'number', 'formatter' => function ($d, $row) {
         $actionUrl = '/admin/menustoremain';
         $actionTransactionUrl = '/admin/transaction';
         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-success btn-default" href="' . $actionUrl . '/detail/' . $d . '"><i class="icon-info-sign"></i></a>
                      <a data-id="' . $d . '" id="' . $d . '" href="' . $actionTransactionUrl . '/inserttransactionmain/' . $d . '" class="btn-xs action action-detail btn btn-danger"><i class="icon-signin"></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($columns, array(), 'admin/menustoremain');
     $table->setTablePrefix('m');
     //        $table->setExtendJoin(
     //            array(
     //                array(" Admin\\Entity\\Transaction", "t", "WITH", " t.menuStoreId = m.id "),
     //                array(" Admin\\Entity\\Supplier", "s", "WITH", " s.id = m.supplier "),
     //            )
     //        );
     $table->setExtendSQl(array(array('AND', 'm.isdelete', '=', '0')));
     $table->setAjaxCall('/admin/menustoremain/index');
     $table->setActionDeleteAll('deleteall');
     $this->tableAjaxRequest($table, $columns, $this->menuStoreModel);
     //end config table
     return new ViewModel(array('table' => $table, 'title' => $this->translator->translate('Manage Warehouse')));
 }