/** * Getting The end javascript * * @return string */ protected function _getEndJs() { $js = parent::_getEndJs(); if (!isset($this->Request['id'])) { die('System ERR: no param passed in!'); } if (trim($this->Request['id']) === 'new') { $order = new Order(); } else { if (!($order = Order::get($this->Request['id'])) instanceof Order) { die('Invalid Order!'); } } if ($order instanceof Order && trim($order->getType()) === Order::TYPE_INVOICE) { header('Location: /orderdetails/' . $order->getId() . '.html?' . $_SERVER['QUERY_STRING']); die; } $cloneOrder = null; if (isset($_REQUEST['cloneorderid']) && !($cloneOrder = Order::get(trim($_REQUEST['cloneorderid']))) instanceof Order) { die('Invalid Order to clone from'); } $paymentMethods = array_map(create_function('$a', 'return $a->getJson();'), PaymentMethod::getAll(true, null, DaoQuery::DEFAUTL_PAGE_SIZE, array('name' => 'asc'))); $shippingMethods = array_map(create_function('$a', 'return $a->getJson();'), Courier::getAll(true, null, DaoQuery::DEFAUTL_PAGE_SIZE, array('name' => 'asc'))); $customer = isset($_REQUEST['customerid']) && ($customer = Customer::get(trim($_REQUEST['customerid']))) instanceof Customer ? $customer->getJson() : null; $js .= "pageJs"; $js .= ".setHTMLID('itemDiv', 'detailswrapper')"; $js .= ".setHTMLID('searchPanel', 'search_panel')"; $js .= ".setCallbackId('searchCustomer', '" . $this->searchCustomerBtn->getUniqueID() . "')"; $js .= ".setCallbackId('searchProduct', '" . $this->searchProductBtn->getUniqueID() . "')"; $js .= ".setCallbackId('saveOrder', '" . $this->saveOrderBtn->getUniqueID() . "')"; $js .= ".setCallbackId('cancelOrder', '" . $this->cancelOrderBtn->getUniqueID() . "')"; $js .= ".setPaymentMethods(" . json_encode($paymentMethods) . ")"; $js .= ".setShippingMethods(" . json_encode($shippingMethods) . ")"; $js .= ".setOrderTypes(" . json_encode(Order::getAllTypes()) . ")"; if ($cloneOrder instanceof Order) { $clonOrderArray = $cloneOrder->getJson(); $clonOrderArray['items'] = array_map(create_function('$a', 'return $a->getJson();'), OrderItem::getAllByCriteria('orderId = ?', array($cloneOrder->getId()))); $js .= ".setOriginalOrder(" . json_encode($clonOrderArray) . ")"; } if ($order instanceof Order && trim($order->getId()) !== '') { $orderArray = $order->getJson(); $orderArray['items'] = array_map(create_function('$a', 'return $a->getJson();'), OrderItem::getAllByCriteria('orderId = ?', array($order->getId()))); $js .= ".setOrder(" . json_encode($orderArray) . ")"; } $js .= ".init(" . json_encode($customer) . ")"; if (!AccessControl::canAccessCreateOrderPage(Core::getRole())) { $js .= ".disableEverything(" . (in_array(Core::getRole()->getId(), array(Role::ID_ACCOUNTING, Role::ID_SALES, Role::ID_PURCHASING)) ? 'true' : '') . ")"; } else { if ($order instanceof Order && trim($order->getId()) !== '' && intval($order->getStatus()->getId()) === OrderStatus::ID_CANCELLED) { $js .= ".disableEverything()"; $js .= ".showModalBox('<h4>Error</h4>', '<h4>This " . $order->getType() . " has been " . $order->getStatus()->getName() . "!</h4><h4>No one can edit it anymore</h4>')"; } } $js .= ";"; return $js; }
public function getMenuItems() { $pageItem = trim($this->getPage()->menuItem); $array = array('' => array('url' => '/', 'name' => 'Home', 'icon' => '<span class="glyphicon glyphicon-home"></span>'), 'Orders' => array('icon' => '<span class="glyphicon glyphicon-search"></span>', 'order' => array('url' => '/order.html', 'name' => 'Orders', 'icon' => '<span class="glyphicon glyphicon-search"></span>'))); /*if(AccessControl::canAccessPriceMatchPage(Core::getRole()) ) $array['priceMatch'] = array('url' => '/pricematch.html', 'name' => 'Price Match', 'icon' => '<span class="glyphicon glyphicon-usd"></span>' );*/ if (AccessControl::canAccessCreateOrderPage(Core::getRole())) { $array['Orders']['neworder'] = array('url' => '/order/new.html', 'name' => 'New Order', 'icon' => '<span class="glyphicon glyphicon-plus"></span>'); } if (AccessControl::canAccessOrderItemsPage(Core::getRole())) { $array['Orders']['orderitems'] = array('url' => '/orderitems.html', 'name' => 'OrderItems'); } if (AccessControl::canAccessOrderItemsPage(Core::getRole())) { $array['Orders']['priceMatch'] = array('url' => '/pricematch.html', 'name' => 'Price Match', 'icon' => '<span class="glyphicon glyphicon-usd"></span>'); } if (AccessControl::canAccessProductsPage(Core::getRole())) { $array['Products'] = array('icon' => '<span class="glyphicon glyphicon-th-list"></span>', 'products' => array('url' => '/products.html', 'name' => 'Products', 'icon' => '<span class="glyphicon glyphicon-th-list"></span>'), 'serialNumbers' => array('url' => '/serialnumbers.html', 'name' => 'Serial Numbers', 'icon' => '<span class="glyphicon glyphicon-search"></span>'), 'manufacturers' => array('url' => '/manufacturers.html', 'name' => 'Manufactures'), 'suppliers' => array('url' => '/suppliers.html', 'name' => 'Suppliers'), 'productcodetypes' => array('url' => '/productcodetypes.html', 'name' => 'Product Code Types', 'icon' => '<span class="glyphicon glyphicon-barcode"></span>'), 'productcategories' => array('url' => '/productcategories.html', 'name' => 'Product Categories')); if (AccessControl::canAccessStockAdjustPage(Core::getRole())) { $array['Products']['stockadjustment'] = array('url' => '/stockadjustment.html', 'name' => 'Stock Adjustment', 'icon' => '<span class=""></span>'); } $array['Products']['productquantitylog'] = array('url' => '/productqtylog.html', 'name' => 'Qty Log', 'icon' => '<span class=""></span>'); $array['Products']['accounting'] = array('url' => '/accounting.html', 'name' => 'Accounting Info', 'icon' => '<span class=""></span>'); $array['Products']['importer'] = array('url' => '/importer/new.html', 'name' => 'Importer', 'icon' => '<span class="fa fa-bars"></span>'); $array['Products']['ageingreport'] = array('url' => '/productageing.html', 'name' => 'Ageing Report (beta)', 'icon' => '<span class="glyphicon glyphicon-eye-open"></span>'); $array['Products']['systembuilds'] = array('url' => '/build.html', 'name' => 'System Builds'); } if (AccessControl::canAccessPurcahseOrdersPage(Core::getRole())) { $array['Purchase'] = array('icon' => '<span class="glyphicon glyphicon-shopping-cart"></span>', 'PurchaseOrder' => array('url' => '/purchase.html', 'name' => 'Purchase Orders', 'icon' => '<span class="glyphicon glyphicon-shopping-cart"></span>'), 'NEW PO' => array('url' => '/purchase/new.html', 'name' => 'NEW PO', 'icon' => '<span class="glyphicon glyphicon-plus"></span>'), 'NEW PO Credit' => array('url' => '/purchase/credit/new.html', 'name' => 'NEW PO Credit', 'icon' => '<span class="glyphicon glyphicon-plus"></span>'), 'Receiving' => array('url' => '/receiving.html', 'name' => 'Receiving PO', 'icon' => '<span class="fa fa-home"></span>'), 'serialNumbers' => array('url' => '/serialnumbers.html', 'name' => 'Serial Numbers', 'icon' => '<span class="glyphicon glyphicon-search"></span>'), 'priceMatch' => array('url' => '/pricematch.html', 'name' => 'Price Match', 'icon' => '<span class="glyphicon glyphicon-usd"></span>')); } if (AccessControl::canAccessOrderItemsPage(Core::getRole())) { $array['Customers'] = array('url' => '/customer.html', 'name' => 'Customers', 'icon' => '<span class="glyphicon glyphicon-user"></span>'); } if (AccessControl::canAccessAccountsPage(Core::getRole())) { $array['Accounts'] = array('icon' => '<span class="glyphicon glyphicon-time"></span>', 'PaymentMethod' => array('url' => '/paymentmethod.html', 'name' => 'Payment Method', 'icon' => '<span class="glyphicon glyphicon-record"></span>'), 'Bill' => array('url' => '/bills.html', 'name' => 'Bills', 'icon' => '<span class="glyphicon glyphicon-usd"></span>'), 'accounting' => array('url' => '/accounting.html', 'name' => 'Accounting Info', 'icon' => '<span class=""></span>'), 'report' => array('url' => '/report.html', 'name' => 'Report', 'icon' => '<span class=""></span>'), 'CreditNote' => array('url' => '/creditnote.html', 'name' => 'Credit Note', 'icon' => '<span class=""></span>'), 'RMA' => array('url' => '/rma.html', 'name' => 'RMA', 'icon' => '<span class=""></span>'), 'importer' => array('url' => '/importer/new.html', 'name' => 'Importer', 'icon' => '<span class="fa fa-bars"></span>')); } if (AccessControl::canAccessLogisticsPage(Core::getRole())) { $array['Logistics'] = array('icon' => '<span class="fa fa-arrows"></span>', 'PurchaseOrder' => array('url' => '/purchase.html', 'name' => 'Purchase Orders', 'icon' => '<span class="glyphicon glyphicon-shopping-cart"></span>'), 'Receiving' => array('url' => '/receiving.html', 'name' => 'Receiving Products', 'icon' => '<span class="fa fa-home"></span>'), 'serialNumbers' => array('url' => '/serialnumbers.html', 'name' => 'Serial Numbers', 'icon' => '<span class="glyphicon glyphicon-search"></span>'), 'Locations' => array('url' => '/locations.html', 'name' => 'Locations', 'icon' => '<span class="fa fa-arrows"></span>'), 'PreferLocationTypes' => array('url' => '/locationtypes.html', 'name' => 'Prefer Location Types', 'icon' => '<span class="glyphicon glyphicon-tasks"></span>')); if (AccessControl::canAccessStockAdjustPage(Core::getRole())) { $array['Logistics']['stockadjustment'] = array('url' => '/stockadjustment.html', 'name' => 'Stock Adjustment', 'icon' => '<span class=""></span>'); } $array['Logistics']['courier'] = array('url' => '/courier.html', 'name' => 'Courier', 'icon' => '<span class=""></span>'); $array['Logistics']['Bill'] = array('url' => '/bills.html', 'name' => 'Supplier Invoices', 'icon' => '<span class="glyphicon glyphicon-usd"></span>'); } if (AccessControl::canAccessWorkShopPage(Core::getRole())) { $array['Workshop'] = array('icon' => '<span class="glyphicon glyphicon-wrench"></span>', 'newTask' => array('url' => '/task/new.html', 'name' => 'New Task', 'icon' => '<span class="glyphicon glyphicon-plus"></span>'), 'tasks' => array('url' => '/tasks.html', 'name' => 'Tasks', 'icon' => '<span class="glyphicon glyphicon-align-left"></span>'), 'newKit' => array('url' => '/kit/new.html', 'name' => 'Build a Kit', 'icon' => '<span class="fa fa-gavel"></span>'), 'kits' => array('url' => '/kits.html', 'name' => 'Kits', 'icon' => '<span class="glyphicon glyphicon-search"></span>')); } if (AccessControl::canAccessReportsPage(Core::getRole())) { $array['Reports'] = array('icon' => '<span class="fa fa-area-chart"></span>', 'Run Rates' => array('url' => '/report/runrate.html', 'name' => 'Run Rate', 'icon' => '<span class="glyphicon glyphicon-plus"></span>')); } if (AccessControl::canAccessUsersPage(Core::getRole())) { $array['Systems'] = array('icon' => '<span class="glyphicon glyphicon-cog"></span>', 'users' => array('url' => '/users.html', 'name' => 'Users', 'icon' => '<span class="glyphicon glyphicon-user"></span>'), 'messages' => array('url' => '/messages.html', 'name' => 'Messages', 'icon' => '<span class="glyphicon glyphicon-envelope"></span>'), 'logs' => array('url' => '/logs.html', 'name' => 'Logs', 'icon' => '<span class="fa fa-book"></span>'), 'systemsettings' => array('url' => '/systemsettings.html', 'name' => 'Settings', 'icon' => '<span class="glyphicon glyphicon-cog"></span>')); } $html = "<ul class='nav navbar-nav'>"; foreach ($array as $key => $item) { $hasNextLevel = !isset($item['name']) && is_array($item) && count($item) > 0; $activeClass = $pageItem === $key || array_key_exists($pageItem, $item) ? 'active' : ''; $html .= "<li class='" . $activeClass . " visible-xs visible-sm visible-md visible-lg'>"; $html .= "<a href='" . ($hasNextLevel === true ? '#' : $item['url']) . "' " . ($hasNextLevel === true ? 'class="dropdown-toggle" data-toggle="dropdown"' : '') . ">"; $html .= (isset($item['icon']) ? $item['icon'] . ' ' : '') . ($hasNextLevel === true ? $key . '<span class="caret"></span>' : $item['name']); $html .= "</a>"; if ($hasNextLevel === true) { $html .= "<ul class='dropdown-menu'>"; foreach ($item as $k => $i) { if (is_string($i) || !isset($i['url'])) { continue; } $html .= "<li class='" . ($pageItem === $k ? 'active' : '') . "'><a href='" . $i['url'] . "'>" . (isset($i['icon']) ? $i['icon'] . ' ' : '') . $i['name'] . "</a></li>"; } $html .= "</ul>"; } $html .= "</li>"; } $html .= "</ul>"; return $html; }