Пример #1
0
 /**
  * Getting The end javascript
  *
  * @return string
  */
 protected function _getEndJs()
 {
     if (!isset($this->Request['id'])) {
         die('System ERR: no param passed in!');
     }
     if (trim($this->Request['id']) === 'new') {
         $purchaseOrder = new PurchaseOrder();
     } else {
         if (!($purchaseOrder = PurchaseOrder::get($this->Request['id'])) instanceof PurchaseOrder) {
             die('Invalid Purchase Order!');
         }
     }
     $comments = array();
     foreach ($purchaseOrder->getComment() as $item) {
         $comments[] = $item->getJson();
     }
     $statusOptions = $purchaseOrder->getStatusOptions();
     $purchaseOrderItems = array();
     foreach (PurchaseOrderItem::getAllByCriteria('purchaseOrderId = ?', array($purchaseOrder->getId()), true, null, DaoQuery::DEFAUTL_PAGE_SIZE, array('updated' => 'desc')) as $item) {
         $product = Product::get($item->getProduct()->getId());
         if (!$product instanceof Product) {
             throw new Exception('Invalid Product passed in!');
         }
         $unitPrice = $item->getUnitPrice();
         $qty = $item->getQty();
         $totalPrice = $item->getTotalPrice();
         $receivedQty = $item->getReceivedQty();
         $purchaseOrderItems[] = array('id' => $item->getId(), 'product' => $product->getJson(), 'unitPrice' => $unitPrice, 'qty' => $qty, 'totalPrice' => $totalPrice, 'receievedQty' => $receivedQty);
     }
     $poitems = $receivingItems = array();
     $js = parent::_getEndJs();
     $js .= "pageJs.setPreData(" . json_encode($purchaseOrder->getJson()) . ")";
     $js .= ".setHTMLID('paymentPanel', 'payment_panel')";
     $js .= ".setHTMLID('totalPriceExcludeGST', 'total_price_exclude_gst')";
     $js .= ".setHTMLID('totalPriceGST', 'total_price_gst')";
     $js .= ".setHTMLID('totalPriceIncludeGST', 'total_price_include_gst')";
     $js .= ".setHTMLID('totalPaidAmount', 'total-paid-amount')";
     $js .= ".setHTMLID('totalShippingCost', 'total-shipping-cost')";
     $js .= ".setComment(" . json_encode($comments) . ")";
     $js .= ".setStatusOptions(" . json_encode($statusOptions) . ")";
     $js .= ".setCallbackId('searchProduct', '" . $this->searchProductBtn->getUniqueID() . "')";
     $js .= ".setCallbackId('saveOrder', '" . $this->saveOrderBtn->getUniqueID() . "')";
     $js .= ".setPurchaseOrderItems(" . json_encode($purchaseOrderItems) . ")";
     $js .= ".load()";
     $js .= "._loadDataPicker()";
     $js .= ".bindAllEventNObjects();";
     return $js;
 }
Пример #2
0
 /**
  * Getting The end javascript
  *
  * @return string
  */
 protected function _getEndJs()
 {
     if (!isset($this->Request['id'])) {
         die('System ERR: no param passed in!');
     }
     if (trim($this->Request['id']) === 'new') {
         $supplier = new Supplier();
     } else {
         if (!($supplier = Supplier::get($this->Request['id'])) instanceof Supplier) {
             die('Invalid Supplier!');
         }
     }
     $js = parent::_getEndJs();
     $js .= "pageJs.setPreData(" . json_encode($supplier->getJson()) . ")";
     $js .= ".load();";
     return $js;
 }
Пример #3
0
 /**
  * Getting The end javascript
  *
  * @return string
  */
 protected function _getEndJs()
 {
     if (!isset($this->Request['id'])) {
         die('System ERR: no param passed in!');
     }
     if (trim($this->Request['id']) === 'new') {
         $customer = new Customer();
         $customer->setBillingAddress(new Address());
         $customer->setShippingAddress(new Address());
     } else {
         if (!($customer = Customer::get($this->Request['id'])) instanceof Customer) {
             die('Invalid Customer!');
         }
     }
     $js = parent::_getEndJs();
     $js .= "pageJs.setPreData(" . json_encode($customer->getJson()) . ")";
     $js .= ".load()";
     $js .= ".bindAllEventNObjects()";
     $js .= "._bindSaveKey();";
     return $js;
 }
Пример #4
0
 /**
  * Getting The end javascript
  *
  * @return string
  */
 protected function _getEndJs()
 {
     $class = $this->_focusEntity;
     $js = parent::_getEndJs();
     $js .= "pageJs";
     if (trim($this->Request['id']) === 'new') {
         $task = $cloneKit = null;
         if (isset($_REQUEST['clonekitid']) && !($cloneKit = Kit::get(trim($_REQUEST['clonekitid']))) instanceof Kit) {
             die('Invalid Kit provided!');
         }
         if (isset($_REQUEST['taskid']) && !($task = Task::get(trim($_REQUEST['taskid']))) instanceof Task) {
             die('Invalid Task provided!');
         }
         $preSetData = array('task' => $task instanceof Task ? $task->getJson() : ($cloneKit instanceof Kit && $cloneKit->getTask() instanceof Task ? $cloneKit->getTask()->getJson() : array()), 'cloneFromKit' => $cloneKit instanceof Kit ? $cloneKit->getJson() : array());
         $js .= ".setPreSetData(" . json_encode($preSetData) . ")";
     }
     $js .= ".setHTMLID('kitsDetailsDiv', 'kits-details-wrapper')";
     $js .= ".setHTMLID('partsTable', 'parts-result-table')";
     $js .= ".load()";
     $js .= ";";
     return $js;
 }
Пример #5
0
 /**
  * Getting The end javascript
  *
  * @return string
  */
 protected function _getEndJs()
 {
     $btnIdnewPO = isset($_REQUEST['btnidnewpo']) && trim($_REQUEST['btnidnewpo']) !== '' ? trim($_REQUEST['btnidnewpo']) : null;
     $manufacturers = array_map(create_function('$a', 'return $a->getJson();'), Manufacturer::getAll());
     $suppliers = array_map(create_function('$a', 'return $a->getJson();'), Supplier::getAll());
     $statuses = array_map(create_function('$a', 'return $a->getJson();'), ProductStatus::getAll());
     $priceTypes = array_map(create_function('$a', 'return $a->getJson();'), ProductPriceType::getAll());
     $codeTypes = array_map(create_function('$a', 'return $a->getJson();'), ProductCodeType::getAll());
     $locationTypes = array_map(create_function('$a', 'return $a->getJson();'), PreferredLocationType::getAll());
     $accountingCodes = array_map(create_function('$a', 'return array("id"=> $a->getId(), "code"=> $a->getCode(), "description"=> $a->getDescription(), "type"=> $a->getTypeId());'), AccountingCode::getAll());
     $js = parent::_getEndJs();
     $js .= "pageJs.setPreData(" . json_encode($manufacturers) . ", " . json_encode($suppliers) . ", " . json_encode($statuses) . ", " . json_encode($priceTypes) . ", " . json_encode($codeTypes) . ", " . json_encode($locationTypes) . ", " . json_encode($btnIdnewPO) . ", " . json_encode($accountingCodes) . ")";
     $js .= ".setCallbackId('getCategories', '" . $this->getCategoriesBtn->getUniqueID() . "')";
     $js .= ".setCallbackId('validateSKU', '" . $this->validateSKUBtn->getUniqueID() . "')";
     $js .= ".load()";
     $js .= ".bindAllEventNObjects()";
     $js .= "._loadChosen();";
     if (!AccessControl::canEditProduct(Core::getRole())) {
         $js .= "pageJs.readOnlyMode();";
     }
     return $js;
 }
Пример #6
0
 /**
  * Getting The end javascript
  *
  * @return string
  */
 protected function _getEndJs()
 {
     $class = $this->_focusEntity;
     $js = parent::_getEndJs();
     $js .= "pageJs";
     if (trim($this->Request['id']) === 'new') {
         $order = $customer = null;
         if (isset($_REQUEST['customerId']) && !($customer = Customer::get(trim($_REQUEST['customerId']))) instanceof Customer) {
             die('Invalid Customer provided!');
         }
         if (isset($_REQUEST['orderId']) && !($order = Order::get(trim($_REQUEST['orderId']))) instanceof Order) {
             die('Invalid Order provided!');
         }
         $preSetData = array('order' => $order instanceof Order ? $order->getJson() : array(), 'customer' => $customer instanceof Customer ? $customer->getJson() : ($order instanceof Order ? $order->getCustomer()->getJson() : array()));
         $js .= ".setPreSetData(" . json_encode($preSetData) . ")";
     }
     $statusArray = array_map(create_function('$a', 'return $a->getJson();'), TaskStatus::getAll());
     $js .= ".setTaskStatuses(" . json_encode($statusArray) . ")";
     $js .= ".load()";
     $js .= ";";
     return $js;
 }