public function onBootstrap(Event $e) { $app = $e->getApplication(); Utility::setSM($app->getServiceManager()); TransactionUtility::setSM($app->getServiceManager()); UnitCalcUtility::setSM($app->getServiceManager()); }
public function __construct() { $config = Utility::getConfig(); $this->sumOption = array('option' => array('curency' => $config['currency'], 'currency_before' => $config['currency_before'], 'number_decimal' => $config['number_decimal'])); $this->sumColumn = array(); parent::__construct(); }
public function prepareElements() { // add() can take either an Element/Fieldset instance, // or a specification, from which the appropriate object // will be built. $translator = Utility::translate(); $this->add(array('name' => 'id', 'attributes' => array('type' => 'hidden'))); $this->add(array('name' => 'company', 'options' => array('label' => $translator->translate('Company')), 'attributes' => array('type' => 'text', 'class' => 'input-xlarge'))); $this->add(array('name' => 'name', 'options' => array('label' => $translator->translate('Name')), 'attributes' => array('type' => 'text', 'class' => 'input-xlarge'))); // $this->add(array( // 'name' => 'supply_for', // 'options' => array( // 'label' => $translator->translate('Supply for'), // ), // 'attributes' => array( // 'type' => 'text', // 'class' => 'input-xlarge' // ), // )); $supArray = Utility::getAllSuplyItemsArray(); $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('multiple' => 'multiple'), 'name' => 'supply_for', 'options' => array('label' => $translator->translate('Product'), 'value_options' => $supArray))); $this->add(array('name' => 'phone', 'options' => array('label' => $translator->translate('Phone')), 'attributes' => array('type' => 'text', 'class' => 'input-xlarge'))); $this->add(array('name' => 'mobile', 'options' => array('label' => $translator->translate('Mobile')), 'attributes' => array('type' => 'text', 'class' => 'input-xlarge'))); $this->add(array('name' => 'email', 'options' => array('label' => $translator->translate('Email')), 'attributes' => array('type' => 'text', 'class' => 'input-xlarge'))); $this->add(array('name' => 'addr', 'options' => array('label' => $translator->translate('addr')), 'attributes' => array('type' => 'textarea', 'class' => 'input-xlarge'))); $this->add(array('name' => 'send', 'attributes' => array('type' => 'submit', 'value' => $translator->translate('Save')))); // We could also define the input filter here, or // lazy-create it in the getInputFilter() method. }
public function prepareElements() { $translator = Utility::translate(); $this->add(array('name' => 'id', 'attributes' => array('type' => 'hidden'))); $this->add(array('name' => 'name', 'options' => array('label' => $translator->translate('Name')), 'attributes' => array('type' => 'text', 'class' => 'input-xlarge'))); $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Save', 'id' => 'submitbutton', 'class' => 'btn btn-danger'))); }
/** * @param array $reportMenu * @return mixed * @throws \PHPExcel_Exception * @throws \PHPExcel_Reader_Exception * */ public static function renderReportMenu($reportMenu = array()) { $arrayOderId = Utility::groupOrderId(); //set val for Excel $row = $beginRow = $countRowMerge = 2; $objPHPExcel = new \PHPExcel(); if (count($reportMenu) < 1 || !isset($reportMenu)) { return ''; } //get header item $header = array(); $i = 0; foreach ($reportMenu[0] as $k => $item) { $header[self::getNameFromNumber($i)] = $k; $i++; } //end get header item //render header foreach ($header as $k => $val) { $objPHPExcel->setActiveSheetIndex(0)->setCellValue($k . '1', $val); $objPHPExcel->getActiveSheet()->getColumnDimension($k)->setWidth(25); } //end render header $rowId = 2; $i = 0; //group by orderId excel foreach ($arrayOderId as $OrderId => $orderIdInfo) { $count = $orderIdInfo['count']; //render item in header foreach ($header as $kHeader => $valHeader) { if (self::checkMerger($valHeader) == true) { $concat = $kHeader . $rowId . ":" . $kHeader . ($rowId + $count - 1); $objPHPExcel->setActiveSheetIndex(0)->mergeCells($concat); //$objPHPExcel->setActiveSheetIndex(0)->setCellValue($kHeader.$rowId,$concat); $cellText = $orderIdInfo[$valHeader]; if ($valHeader == 'order_create_date') { $cellText = date('d-m-Y', $orderIdInfo[$valHeader]); } $objPHPExcel->setActiveSheetIndex(0)->setCellValue($kHeader . $rowId, $cellText); } } //end render item header $rowId = $rowId + $count; $i++; } //end group by orderId excel foreach ($reportMenu as $orderIdInfo) { foreach ($header as $kHeader => $valHeader) { if (self::checkMerger($valHeader) != true) { $cellText = $orderIdInfo[$valHeader]; $objPHPExcel->setActiveSheetIndex(0)->setCellValue($kHeader . $row, $cellText); } } $row++; } $strLink = self::createExcelLink(time()); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save($strLink); return str_replace('public/', '', $strLink); }
public function logoutAction() { Utility::insertHistory('logout'); $auth = new AuthenticationService(); $auth->clearIdentity(); $this->redirect()->toRoute('admin/child', array('controller' => 'login')); }
public function indexAction() { //$this->modelUsers->createQuery(''); $users = $this->modelUsers->findBy(array('isdelete' => '0')); //tableTitle = table heading //datarow row of table... render by heading key //heading key = table column name $dataRow = $this->modelUsers->convertToArray($users); $data = array('title' => $this->translator->translate('Login'), 'link' => '/frontend/login', 'buttonLogin' => $this->translator->translate('Login'), 'userNameText' => $this->translator->translate('User name'), 'passwordText' => $this->translator->translate('Password')); if ($this->getRequest()->isPost()) { $userName = $this->params()->fromPost('userName'); $password = $this->params()->fromPost('password'); $data = $this->params()->fromPost(); //login here $login_obj = new AuthenticationService(null, $this->modelUsers); $this->modelUsers->setLoginUser($data); $login_obj->authenticate(); //check login $user = Utility::checkLogin($this); if ($user != null) { Utility::insertHistory('login'); $this->redirect()->toRoute('frontend/child', array('controller' => 'table')); } else { $this->redirect()->toRoute('frontend/child', array('controller' => 'login')); } //end check login } return new ViewModel($data); }
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 onDispatch(\Zend\Mvc\MvcEvent $e) { $install = setupUtility::checkInstall(); if ($install == true) { return $this->redirect()->toRoute('install'); } //get doctrine service $this->serviceLocatorStr = 'doctrine'; $this->sm = $this->getServiceLocator(); $this->doctrineService = $this->sm->get($this->serviceLocatorStr); //get translate service $this->translator = Utility::translate(); //check login $user = Utility::checkLogin(); if (!is_object($user) && $user == 0) { $this->redirect()->toRoute('frontend/child', array('controller' => 'login')); } //start acl // $acl = new myAcl(); // $currentRoute = $this->getModuleCurrentRoute($e); // $isOk = $acl->checkRole(UtilityRoleLevel::convertUserTypeToRole($user->userType)['role'],$currentRoute); // if(!$isOk || $isOk == '' || $isOk == null){ // return $this->redirect()->toRoute('frontend/child', array('controller' => 'login')); // } //end check login //end acl $this->init(); return parent::onDispatch($e); }
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 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 addAction() { $viewData = Utility::addNewOrder($this->params(), $this->getRequest(), 'frontend/child'); if ($viewData['orderId'] != 0) { $this->redirect()->toRoute('frontend/child', array('controller' => 'order', 'action' => 'detail', 'id' => $viewData['orderId'])); } return new ViewModel($viewData); }
public static function convertMenuTypeReportArray($data) { foreach ($data as $k => $val) { $data[$k]['costType'] = Utility::getMenuCostType($data[$k]['costType']); $data[$k]['realCost'] = number_format($data[$k]['realCost']); $data[$k]['id'] = $k; } return $data; }
public function __construct($name = null) { $translator = Utility::translate(); parent::__construct('AdminCategories'); $this->setAttribute('method', 'post'); $this->add(array('name' => 'name', 'attributes' => array('type' => 'Text'))); $this->add(array('name' => 'id', 'attributes' => array('type' => 'Hidden'))); $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => $translator->translate('Save'), 'id' => 'submitbutton', 'class' => 'btn btn-primary'))); }
public function convertSingleToArray($user) { $array = array(); $array['userName'] = $user->getUserName(); $array['id'] = $user->getId(); $array['password'] = $user->getPassword(); $array['fullName'] = $user->getFullName(); $array['type'] = Utility::getUserRole($user->getType()); return $array; }
public function onDispatch(\Zend\Mvc\MvcEvent $e) { $service_locator_str = 'doctrine'; $this->postPerPage = 10; $this->sm = $this->getServiceLocator(); $this->doctrineService = $this->sm->get($service_locator_str); $this->translator = Utility::translate(); $this->init(); return parent::onDispatch($e); }
public function init() { $this->modelCategories = new categoryModel($this->doctrineService); $this->translator = Utility::translate(); //check login $user = Utility::checkLogin($this); if (!is_object($user) && $user == 0) { $this->redirect()->toRoute('frontend/child', array('controller' => 'login')); } parent::init(); }
public function prepareElements() { $translator = Utility::translate(); $this->add(array('name' => 'id', 'attributes' => array('type' => 'hidden'))); $supArray = Utility::getPaymentCategoryArray(); $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'attributes' => array(), 'name' => 'categoryId', 'options' => array('label' => $translator->translate('Category'), 'value_options' => $supArray, 'selected' => true))); $this->add(array('name' => 'title', 'options' => array('label' => $translator->translate('Title')), 'attributes' => array('type' => 'text', 'class' => 'input-xlarge'))); $this->add(array('name' => 'value', 'options' => array('label' => $translator->translate('Value')), 'attributes' => array('type' => 'text', 'class' => 'input-xlarge'))); $this->add(array('name' => 'reason', 'options' => array('label' => $translator->translate('Reason')), 'attributes' => array('type' => 'textarea', 'class' => 'input-xlarge jqueryte'))); $this->add(array('name' => 'time', 'attributes' => array('type' => 'text', 'class' => 'input-xlarge date-picker'))); $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Go', 'id' => 'submitbutton', 'class' => 'btn btn-danger'))); }
public function prepareElements() { $translator = Utility::translate(); $this->add(array('name' => 'id', 'attributes' => array('type' => 'hidden'))); $this->add(array('name' => 'name', 'options' => array('label' => $translator->translate('Name')), 'attributes' => array('type' => 'text', 'class' => 'input-xlarge'))); $this->add(array('name' => 'quantity', 'options' => array('label' => $translator->translate('Quantity')), 'attributes' => array('type' => 'text', 'class' => 'input-xlarge'))); $supArray = Utility::getAllSuplyItemsArray(); $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('id' => 'supplierItemId'), 'name' => 'supplierItemId', 'options' => array('label' => $translator->translate('Supplier item'), 'value_options' => $supArray, 'selected' => true))); $this->add(array('name' => 'supplierItemName', 'options' => array('label' => $translator->translate('Supplier Item Name')), 'attributes' => array('type' => 'text', 'class' => 'input-xlarge', 'id' => 'supplierItemName', 'readonly' => 'readonly'))); $this->add(array('name' => 'note', 'options' => array('label' => $translator->translate('Note')), 'attributes' => array('type' => 'textarea', 'class' => 'input-xlarge'))); $this->add(array('name' => 'time', 'options' => array('label' => $translator->translate('Time')), 'attributes' => array('type' => 'text', 'class' => 'input-xlarge date-picker'))); $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => $translator->translate('Save'), 'id' => 'submitbutton', 'class' => 'btn btn-primary span3 typeahead'))); }
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' => 'Category', 'db' => 'catId', 'dt' => 2, 'search' => false, 'type' => 'number', 'dataSelect' => Utility::getCategoryForSelect()), array('title' => 'Cost', 'db' => 'cost', 'dt' => 3, 'search' => false, 'type' => 'number'), array('title' => 'Take Away cost', 'db' => 'taCost', 'dt' => 4, 'search' => false, 'type' => 'number')); /////end column for table $table = new AjaxTable($columns, array(), 'frontend/com'); $table->setTablePrefix('m'); $table->setExtendSQl(array(array('AND', 'm.isdelete', '=', '0'), array('AND', 'm.isCombo', '=', '1'))); $table->setAjaxCall('/frontend/com'); $table->setActionDeleteAll('deleteall'); $this->tableAjaxRequest($table, $columns, $this->modelMenu); //end config table return new ViewModel(array('table' => $table, 'title' => array('title' => $this->translator->translate('Combo')))); }
public function prepareElements() { // add() can take either an Element/Fieldset instance, // or a specification, from which the appropriate object // will be built. $translator = Utility::translate(); $this->add(array('name' => 'id', 'attributes' => array('type' => 'hidden'))); $this->add(array('name' => 'value', 'options' => array('label' => $translator->translate('Value')), 'attributes' => array('type' => 'text', 'class' => 'input-xlarge'))); $this->add(array('name' => 'isdelete', 'attributes' => array('type' => 'hidden'))); $this->add(array('name' => 'send', 'attributes' => array('type' => 'submit', 'value' => $translator->translate('Save')))); // We could also define the input filter here, or // lazy-create it in the getInputFilter() method. }
public function addAction() { $request = $this->getRequest(); $id = $this->params()->fromRoute('id'); //insert if ($id == '') { if ($request->isPost()) { $checkExist = Utility::checkUserExist($this->params()->fromPost('userName')); if ($checkExist == true) { $this->flashMessenger()->addSuccessMessage("User existed"); return $this->redirect()->toRoute('admin/child', array('controller' => 'users', 'action' => 'add')); } $cat = new User(); $cat->setUserName($this->params()->fromPost('userName')); $cat->setFullName($this->params()->fromPost('fullName')); $cat->setPassword(sha1($this->params()->fromPost('password'))); $cat->setIsdelete(0); $cat->setType($this->params()->fromPost('usertype')); $userInserted = $this->modelUsers->insert($cat); //flash $this->flashMessenger()->addSuccessMessage("Insert success"); return $this->redirect()->toRoute('admin/child', array('controller' => 'users')); } //insert new user //$this->redirect()->toRoute('admin/child',array('controller'=>'category')); return new ViewModel(array('title' => $this->translator->translate('Add new user'))); } else { $cat = $this->modelUsers->findOneBy(array('id' => $id)); if ($request->isPost()) { //check exist $checkExist = Utility::checkUserExist($this->params()->fromPost('userName')); if ($checkExist == true) { $this->flashMessenger()->addSuccessMessage("User existed"); return $this->redirect()->toRoute('admin/child', array('controller' => 'users', 'action' => 'add', 'id' => $cat->getId())); } $idFormPost = $this->params()->fromPost('id'); $cat = $this->modelUsers->findOneBy(array('id' => $idFormPost)); $cat->setUserName($this->params()->fromPost('userName')); $cat->setFullName($this->params()->fromPost('fullName')); $cat->setType($this->params()->fromPost('usertype')); if ($this->params()->fromPost('password') != '') { $cat->setPassword(sha1($this->params()->fromPost('password'))); } $this->modelUsers->edit($cat); //flash $this->flashMessenger()->addSuccessMessage("Update success"); return $this->redirect()->toRoute('admin/child', array('controller' => 'users')); } return new ViewModel(array('data' => $cat, 'title' => $this->translator->translate('Edit User:') . $cat->getUserName())); } }
public function convertSingleToArray($data) { $tableInfo = Utility::getTableInfo($data->getTableid()); $config = Utility::getConfig(); $code = ''; $value = ''; $desc = ''; if ($data->getCouponId() != -1) { $coupon = Utility::getCouponInfo($data->getCouponId()); // echo '<pre>'; // print_r($coupon); // echo '</pre>'; $code = $coupon->getCode(); if ($coupon->getReuse() == 1) { $code = $coupon->getDescription(); } $type = $coupon->getType(); if ($type == 0) { $value = 'Reduce :' . number_format($coupon->getValue()) . ' ' . $config['currency']; } else { $value = 'Reduce :' . $coupon->getValue() . '%'; } $desc = $coupon->getDescription(); } $userInfo = Utility::getUserInfo($data->getUserId()); $surtax = Utility::getSurTaxInfo($data->getSurtaxId()); if ($surtax) { $surtaxType = $surtax->getType(); $surtaxValue = $surtax->getValue(); } else { $surtaxType = 'Cash'; $surtaxValue = 0; } $taxType = Utility::convertSurtaxType($surtaxType); //print_r($coupon); $array = array(); $array['id'] = $data->getId(); $array['tableId'] = $tableInfo->getName(); $array['createDate'] = date('d/m/Y h:i:s', $data->getCreateDate()); $array['totalCost'] = number_format($data->getTotalCost()); $array['totalRealCost'] = number_format($data->getTotalRealCost()); $array['coupon'] = $code; $array['couponValue'] = $value; $array['couponDesc'] = $desc; $array['surtax'] = number_format($surtaxValue) . ' ' . $taxType; $array['userid'] = $userInfo->getUserName(); $array['status'] = $data->getStatus(); $array['customer_id'] = $data->getCustomerId(); $array['newDate'] = $data->getNewDate(); return $array; }
public function convertSingleToArray($user) { $paymentCategory = Utility::getPaymentCateInfo($user->getCategoryId()); $date = $user->getTime(); $date == '' ? $time = time() : ($time = $date); $array = array(); $array['id'] = $user->getId(); $array['title'] = $user->getTitle(); $array['value'] = number_format($user->getValue()); $array['reason'] = $user->getReason(); $array['time'] = date('d-m-Y', $time); $array['categoryId'] = $user->getCategoryId(); return $array; }
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 convertToArray($datas) { $return = array(); foreach ($datas as $data) { $convertList = Utility::getUnitConverted($data->getId()); $convertList = json_encode($convertList); $array = array(); $array['id'] = $data->getId(); $array['name'] = $data->getName(); $array['converted'] = $convertList; $return[] = $array; } return $return; }
public function prepareElements() { // add() can take either an Element/Fieldset instance, // or a specification, from which the appropriate object // will be built. $this->add(array('name' => 'id', 'attributes' => array('type' => 'hidden'))); $value_option = Utility::getUnitListForSelect(); $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'unit_item_one', 'options' => array('value_options' => $value_option, 'label' => 'Unit Item 1'), 'attributes' => array('class' => 'input-xlarge span12'))); $this->add(array('name' => 'value', 'attributes' => array('type' => 'text'), 'options' => array('label' => 'Convert Value'))); $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'unit_item_two', 'options' => array('value_options' => $value_option, 'label' => 'Unit Item 2'), 'attributes' => array('class' => 'input-xlarge span12'))); $this->add(array('name' => 'send', 'attributes' => array('type' => 'submit', 'value' => 'Submit'))); // We could also define the input filter here, or // lazy-create it in the getInputFilter() method. }
public function convertToArray($datas) { $return = array(); foreach ($datas as $data) { $userInfo = Utility::getUserInfo($data->getUserId()); $array = array(); $array['id'] = $data->getId(); $array['userId'] = $userInfo->getFullName(); $array['action'] = $data->getAction(); $array['time'] = date("d-m-y H:i:s", $data->getTime()); $return[] = $array; } return $return; }
public function addAction() { $request = $this->getRequest(); if ($request->isPost()) { $data = $this->params()->fromPost(); echo json_encode($data); die; //check api $userApi = Utility::userApi($data['userName'], $data['apiKey']); if ($userApi->getId() == '') { die(-1); } $this->userId = $userApi->getId(); //end check api // insert new customer before insert new order $customerId = Utility::createCustomer($data); //insert new order $order = new Orders(); $order->setUserId($this->userId); $order->setStatus($data['status']); $order->setTotalCost($data['total_cost']); $order->setTotalRealCost($data['total_real_cost']); $order->setCreateDate(time()); $order->setIsdelete(0); $order->setTableId(0); $order->setSurtaxId(0); $order->setCustomerId($customerId); //end insert new order $order = $this->orderModel->insert($order); $orderId = $order->getId(); //insert orderDetail $orderDetails = $data['detai']; foreach ($orderDetails as $details) { $orderDetail = new OrderDetail(); $orderDetail->setOrderId($orderId); $orderDetail->setMenuId($details['menu_id']); $orderDetail->setCostType($details['cost_type']); $orderDetail->setQuantity($details['quantity']); $orderDetail->setMenuCost($details['menu_cost']); $orderDetail->setRealCost($details['real_cost']); $orderDetail->setCustomerId($customerId); $orderDetail->setIsdelete(0); $this->orderDetailModel->insert($orderDetail); } //insert order detail die; } die; }
public function convertSingleToArray($data) { $parentMenu = Utility::getMenuInfo($data->getMenuParentId()); $childMenu = Utility::getMenuInfo($data->getMenuChildId()); $array = array(); $array['id'] = $data->getId(); $array['menu_parent_id'] = $parentMenu->getName(); $array['menu_child_id'] = $childMenu->getName(); $array['menu_quantity'] = $data->getMenuQuantity(); $array['menu_cost'] = $childMenu->getCost(); $array['menu_ta_cost'] = $childMenu->getTakeAwayCost(); $array['menu_total_cost'] = $childMenu->getCost() * $data->getMenuQuantity(); $array['menu_total_ta_cost'] = $childMenu->getTakeAwayCost() * $data->getMenuQuantity(); return $array; }