/** * Getting the connector * * @param Courier $courier The courier this connector is for * * @return multitype: */ public static function getConnector(Courier $courier) { if (!isset(self::$_cache[$courier->getId()])) { $className = trim($courier->getConnector()); self::$_cache[$courier->getId()] = new $className($courier); } return self::$_cache[$courier->getId()]; }
public function adminInvoice($id) { if (isset($id)) { $order = Order::find($id); if (isset($order)) { // Session::put('order_id', $id); $orderItems = OrderItem::where('order_id', $order->id)->get(); $couriers = Courier::where('status', 'active')->get(); $pdf = PDF::loadView('pdf.adminInvoice', ['order' => $order, 'orderItems' => $orderItems, 'couriers' => $couriers]); // return $pdf->download('invoice.pdf'); return $pdf->stream(); } else { return Redirect::to('/'); } } else { return Redirect::to('/'); } }
protected function SetupCourier() { // Lookup Object PK information from Query String (if applicable) // Set mode to Edit or New depending on what's found $intCourierId = QApplication::QueryString('intCourierId'); if ($intCourierId) { $this->objCourier = Courier::Load($intCourierId); if (!$this->objCourier) { throw new Exception('Could not find a Courier object with PK arguments: ' . $intCourierId); } $this->strTitleVerb = QApplication::Translate('Edit'); $this->blnEditMode = true; } else { $this->objCourier = new Courier(); $this->strTitleVerb = QApplication::Translate('Create'); $this->blnEditMode = false; } }
protected function dtgCourier_Bind() { // Because we want to enable pagination AND sorting, we need to setup the $objClauses array to send to LoadAll() // Remember! We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below $this->dtgCourier->TotalItemCount = Courier::CountAll(); // Setup the $objClauses Array $objClauses = array(); // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add // the OrderByClause to the $objClauses array if ($objClause = $this->dtgCourier->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->dtgCourier->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be the array of all Courier objects, given the clauses above $this->dtgCourier->DataSource = Courier::LoadAll($objClauses); }
/** * Getting The end javascript * * @return string */ protected function _getEndJs() { $class = get_called_class(); $js = $this->_getJSPrefix(); $js .= parent::_getEndJs(); $paymentMethods = array_map(create_function('$a', 'return $a->getJson();'), PaymentMethod::getAll()); $shippingMethods = array_map(create_function('$a', 'return $a->getJson();'), Courier::getAll()); $supplier = isset($_REQUEST['supplierid']) && ($supplier = Supplier::get(trim($_REQUEST['supplierid']))) instanceof Supplier ? $supplier->getJson() : null; $js .= "pageJs"; $js .= ".setHTMLID('itemDiv', 'detailswrapper')"; $js .= ".setHTMLID('searchPanel', 'search_panel')"; $js .= ".setCallbackId('searchSupplier', '" . $this->searchSupplierBtn->getUniqueID() . "')"; $js .= ".setCallbackId('searchProduct', '" . $this->searchProductBtn->getUniqueID() . "')"; $js .= ".setCallbackId('saveOrder', '" . $this->saveOrderBtn->getUniqueID() . "')"; $js .= ".setPaymentMethods(" . json_encode($paymentMethods) . ")"; $js .= ".setShippingMethods(" . json_encode($shippingMethods) . ")"; $js .= ".init(" . json_encode($supplier) . ");"; return $js; }
public static function saveInvoice($id) { if (isset($id)) { $order = Order::find($id); if (isset($order)) { // Session::put('order_id', $id); $orderItems = OrderItem::where('order_id', $order->id)->get(); $couriers = Courier::where('status', 'active')->get(); $pdf = PDF::loadView('pdf.adminInvoice', ['order' => $order, 'orderItems' => $orderItems, 'couriers' => $couriers]); $output = $pdf->output(); $file_to_save = './public/uploads/pdf/order_' . $order->id . '.pdf'; file_put_contents($file_to_save, $output); return true; } else { return Redirect::to('/'); } } else { return Redirect::to('/'); } }
/** * requireDefaultRecords * Populate the Courier DataObject with information about our courier, so that it installs correctly. * * @return void */ public function requireDefaultRecords() { /* Inherit Default Record Creation */ parent::requireDefaultRecords(); $courier_name = get_class($this); /* If no records exist, create defaults */ if (!DataObject::get_one($courier_name)) { $n = new $courier_name(); //Disable the courier by default. $n->Enabled = 0; //System name for this gateway $n->SystemName = "Flat Rate Per Item"; //Friendly name for this courier. $n->Title = "Flat Rate Per Item"; //Default minimum spend $n->FlatRate = 0; //Write our configuration changes to the courier database tables. $n->write(); unset($n); DB::alteration_message('Successfully installed the courier "' . $courier_name . '"', 'created'); } }
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, Courier::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }
define('STATUS_ERROR', 2); $status = STATUS_DEFAULT; $confirmationCode = $_GET['confirmationCode']; $EmailRegistration = new EmailRegistration(); try { $EmailRegistration->fetchByConfirmationCode($confirmationCode); $EmailRegistration->confirm(); $Email = new Email(); $Email->subject = "Confirm Registration"; $Email->recipient = $EmailRegistration->email; $Email->sender = '*****@*****.**'; $Email->message_html = file_get_contents('emails/confirm.htm'); $Courier = new Courier(); $Courier->send($Email); $status = STATUS_SUCCESS; } catch(Exception $e) { $status = STATUS_ERROR; } switch($status) { case STATUS_SUCCESS: ?> <h1>Success</h1> <p>Your email address, <?php echo $EmailRegistration->email; ?>
public function getCourier() { $q = Input::get('term'); $q = '%' . $q . '%'; $couriers = Courier::where('name', 'like', $q)->where('status', '=', 'active')->get(); $result = array(); foreach ($couriers as $d) { $result[] = array('id' => $d->_id, 'value' => $d->name, 'name' => $d->name, 'label' => $d->name . ' ( ' . $d->_id . ' )'); } return Response::json($result); }
return "OK!"; }); Route::get('test_add_best', function () { BestSelling::increase(6); }); //Untuk kepentingan debugging. bisa dihapus kemudian hari Route::get('hapuscart', function () { Session::forget('shopping_cart'); Session::forget('shopping_cart["item"]'); Session::forget('shopping_cart["totalprice"]'); }); Route::get('test_locations', function () { $q = "vaio"; $category = 6; $location = "Nangroe Aceh Darussalam"; $products = Product::leftJoin('brands', function ($j) { $j->on('products.brand_id', '=', 'brands.id'); })->leftJoin('users', function ($j) { $j->on('products.seller_id', '=', 'users.id'); })->leftJoin('locations', function ($j) { $j->on('users.location_id', '=', 'locations.id'); })->select('products.*')->where('products.name', 'like', '%' . $q . '%')->orWhere('brands.name', 'like', '%' . $q . '%'); $products->where('category_id', '=', $category); $products->where('locations.province', '=', $location); foreach ($products->get() as $product) { echo $product->name . " " . $product->location; } }); Route::get('courier_test', function () { return Courier::all()->first()->company_name; });
public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) { if ($objObject->objTransaction) { $objObject->objTransaction = Transaction::GetSoapObjectFromObject($objObject->objTransaction, false); } else { if (!$blnBindRelatedObjects) { $objObject->intTransactionId = null; } } if ($objObject->objFromCompany) { $objObject->objFromCompany = Company::GetSoapObjectFromObject($objObject->objFromCompany, false); } else { if (!$blnBindRelatedObjects) { $objObject->intFromCompanyId = null; } } if ($objObject->objFromContact) { $objObject->objFromContact = Contact::GetSoapObjectFromObject($objObject->objFromContact, false); } else { if (!$blnBindRelatedObjects) { $objObject->intFromContactId = null; } } if ($objObject->objFromAddress) { $objObject->objFromAddress = Address::GetSoapObjectFromObject($objObject->objFromAddress, false); } else { if (!$blnBindRelatedObjects) { $objObject->intFromAddressId = null; } } if ($objObject->objToCompany) { $objObject->objToCompany = Company::GetSoapObjectFromObject($objObject->objToCompany, false); } else { if (!$blnBindRelatedObjects) { $objObject->intToCompanyId = null; } } if ($objObject->objToContact) { $objObject->objToContact = Contact::GetSoapObjectFromObject($objObject->objToContact, false); } else { if (!$blnBindRelatedObjects) { $objObject->intToContactId = null; } } if ($objObject->objToAddress) { $objObject->objToAddress = Address::GetSoapObjectFromObject($objObject->objToAddress, false); } else { if (!$blnBindRelatedObjects) { $objObject->intToAddressId = null; } } if ($objObject->objCourier) { $objObject->objCourier = Courier::GetSoapObjectFromObject($objObject->objCourier, false); } else { if (!$blnBindRelatedObjects) { $objObject->intCourierId = null; } } if ($objObject->dttShipDate) { $objObject->dttShipDate = $objObject->dttShipDate->__toString(QDateTime::FormatSoap); } if ($objObject->objCreatedByObject) { $objObject->objCreatedByObject = UserAccount::GetSoapObjectFromObject($objObject->objCreatedByObject, false); } else { if (!$blnBindRelatedObjects) { $objObject->intCreatedBy = null; } } if ($objObject->dttCreationDate) { $objObject->dttCreationDate = $objObject->dttCreationDate->__toString(QDateTime::FormatSoap); } if ($objObject->objModifiedByObject) { $objObject->objModifiedByObject = UserAccount::GetSoapObjectFromObject($objObject->objModifiedByObject, false); } else { if (!$blnBindRelatedObjects) { $objObject->intModifiedBy = null; } } return $objObject; }
protected function lstCourier_Create() { $this->lstCourier = new QListBox($this); $this->lstCourier->Name = QApplication::Translate('Courier'); $this->lstCourier->AddItem(QApplication::Translate('- Select One -'), null); $objCourierArray = Courier::LoadAll(); if ($objCourierArray) { foreach ($objCourierArray as $objCourier) { $objListItem = new QListItem($objCourier->__toString(), $objCourier->CourierId); if ($this->objShipment->Courier && $this->objShipment->Courier->CourierId == $objCourier->CourierId) { $objListItem->Selected = true; } $this->lstCourier->AddItem($objListItem); } } }
/** * Creating a new shippment * * @param Address $address * @param Courier $courier * @param string $consignmentNo * @param string $shippingDate * @param Order $order * @param string $contactName * @param string $contactNo * @param number $noOfCartons * @param string $estShippingCost The est shipping cost * @param string $actualShippingCost The actual shipping cost * @param string $deliveryInstructions The delivery instructions * @param string $mageShipmentId The magento shippment id * * @return Shippment */ public static function create(Address $address, Courier $courier, $consignmentNo, $shippingDate, Order $order, $contactName, $contactNo = '', $noOfCartons = 0, $estShippingCost = '0.00', $actualShippingCost = '0.00', $deliveryInstructions = '', $mageShipmentId = '') { $shippment = new Shippment(); if (($shippingDate = trim($shippingDate)) === '') { $shippingDate = new UDate(); } $estShippingCost = StringUtilsAbstract::getValueFromCurrency(trim($estShippingCost)); $actualShippingCost = StringUtilsAbstract::getValueFromCurrency(trim($actualShippingCost)); $msg = 'Shipment create for Order(' . $order->getOrderNo() . ') to address(' . trim($address) . ') via Courier(' . $courier->getName() . ') with ConNote(=' . $consignmentNo . ') on ' . $shippingDate . '(UTC) with actualCost = ' . StringUtilsAbstract::getCurrency($actualShippingCost); $shippment = $shippment->setAddress($address)->setCourier($courier)->setConNoteNo(trim($consignmentNo))->setOrder($order)->setReceiver(trim($contactName))->setContact(trim($contactNo))->setShippingDate(trim($shippingDate))->setNoOfCartons(trim($noOfCartons))->setEstShippingCost($estShippingCost)->setActualShippingCost($actualShippingCost)->setDeliveryInstructions(trim($deliveryInstructions))->setMageShipmentId(trim($mageShipmentId))->setActive(true)->save()->addLog($msg, Log::TYPE_SYSTEM, get_class($shippment) . '_CREATION', __CLASS__ . '::' . __FUNCTION__); $order->addComment($msg, Comments::TYPE_SYSTEM)->addLog($msg, Log::TYPE_SYSTEM, 'Auto Log', __CLASS__ . '::' . __FUNCTION__); return $shippment; }
/** * Main utility method to aid with data binding. It is used by the default BindAllRows() databinder but * could and should be used by any custom databind methods that would be used for instances of this * MetaDataGrid, by simply passing in a custom QQCondition and/or QQClause. * * If a paginator is set on this DataBinder, it will use it. If not, then no pagination will be used. * It will also perform any sorting (if applicable). * * @param QQCondition $objConditions override the default condition of QQ::All() to the query, itself * @param QQClause[] $objOptionalClauses additional optional QQClause object or array of QQClause objects for the query * @return void */ public function MetaDataBinder(QQCondition $objCondition = null, $objOptionalClauses = null) { // Setup input parameters to default values if none passed in if (!$objCondition) { $objCondition = QQ::All(); } $objClauses = $objOptionalClauses ? $objOptionalClauses : array(); // We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below if ($this->Paginator) { $this->TotalItemCount = Courier::QueryCount($objCondition, $objClauses); } // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add // the OrderByClause to the $objClauses array if ($objClause = $this->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be a Query result from Courier, given the clauses above $this->DataSource = Courier::QueryArray($objCondition, $objClauses); }
public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) { if ($objObject->objCourier) { $objObject->objCourier = Courier::GetSoapObjectFromObject($objObject->objCourier, false); } else { if (!$blnBindRelatedObjects) { $objObject->intCourierId = null; } } return $objObject; }
protected function lstCourier_Create() { $this->lstCourier = new QListBox($this); $this->lstCourier->Name = 'Courier'; $this->lstCourier->AddItem('- Select One -', null, true); $objCourierArray = Courier::LoadAll(); if ($objCourierArray) { foreach ($objCourierArray as $objCourier) { $this->lstCourier->AddItem($objCourier->__toString(), $objCourier->CourierId); } } }
public function listCouriers($status, $page) { $adminId = Session::get('admin_id'); if (!isset($adminId)) { return json_encode(array('message' => 'not logged')); } $couriers = Courier::where('status', '=', $status)->get(); if (isset($couriers) && count($couriers) > 0) { return json_encode(array('message' => 'found', 'couriers' => $couriers->toArray())); } else { return json_encode(array('message' => 'empty')); } }
/** * saveOrder * * @param unknown $sender * @param unknown $param * * @throws Exception * */ public function saveOrder($sender, $param) { $results = $errors = array(); try { Dao::beginTransaction(); $customer = Customer::get(trim($param->CallbackParameter->customer->id)); if (!$customer instanceof Customer) { throw new Exception('Invalid Customer passed in!'); } if (!isset($param->CallbackParameter->type) || ($type = trim($param->CallbackParameter->type)) === '' || !in_array($type, Order::getAllTypes())) { throw new Exception('Invalid type passed in!'); } $order = null; if (isset($param->CallbackParameter->orderId) && ($orderId = trim($param->CallbackParameter->orderId)) !== '') { if (!($order = Order::get($orderId)) instanceof Order) { throw new Exception('Invalid Order to edit!'); } } $orderCloneFrom = null; if (isset($param->CallbackParameter->orderCloneFromId) && ($orderCloneFromId = trim($param->CallbackParameter->orderCloneFromId)) !== '') { if (!($orderCloneFrom = Order::get($orderCloneFromId)) instanceof Order) { throw new Exception('Invalid Order to clone from!'); } } $shipped = isset($param->CallbackParameter->shipped) && intval($param->CallbackParameter->shipped) === 1; $poNo = isset($param->CallbackParameter->poNo) && trim($param->CallbackParameter->poNo) !== '' ? trim($param->CallbackParameter->poNo) : ''; if (isset($param->CallbackParameter->shippingAddr)) { $shippAddress = $order instanceof Order ? $order->getShippingAddr() : null; $shippAddress = Address::create($param->CallbackParameter->shippingAddr->street, $param->CallbackParameter->shippingAddr->city, $param->CallbackParameter->shippingAddr->region, $param->CallbackParameter->shippingAddr->country, $param->CallbackParameter->shippingAddr->postCode, $param->CallbackParameter->shippingAddr->contactName, $param->CallbackParameter->shippingAddr->contactNo, $param->CallbackParameter->shippingAddr->companyName, $shippAddress); } else { $shippAddress = $customer->getShippingAddress(); } $printItAfterSave = false; if (isset($param->CallbackParameter->printIt)) { $printItAfterSave = intval($param->CallbackParameter->printIt) === 1 ? true : false; } if (!$order instanceof Order) { $order = Order::create($customer, $type, null, '', OrderStatus::get(OrderStatus::ID_NEW), new UDate(), false, $shippAddress, $customer->getBillingAddress(), false, $poNo, $orderCloneFrom); } else { $order->setType($type)->setPONo($poNo)->save(); } $totalPaymentDue = 0; if (trim($param->CallbackParameter->paymentMethodId)) { $paymentMethod = PaymentMethod::get(trim($param->CallbackParameter->paymentMethodId)); if (!$paymentMethod instanceof PaymentMethod) { throw new Exception('Invalid PaymentMethod passed in!'); } $totalPaidAmount = trim($param->CallbackParameter->totalPaidAmount); $order->addPayment($paymentMethod, $totalPaidAmount); $order = Order::get($order->getId()); $order->addInfo(OrderInfoType::ID_MAGE_ORDER_PAYMENT_METHOD, $paymentMethod->getName(), true); if ($shipped === true) { $order->setType(Order::TYPE_INVOICE); } } else { $paymentMethod = ''; $totalPaidAmount = 0; } foreach ($param->CallbackParameter->items as $item) { $product = Product::get(trim($item->product->id)); if (!$product instanceof Product) { throw new Exception('Invalid Product passed in!'); } if (isset($item->active) && intval($item->active) === 1 && intval($product->getActive()) !== 1 && $type === Order::TYPE_INVOICE) { throw new Exception('Product(SKU:' . $product->getSku() . ') is DEACTIVATED, please change it to be proper product before converting it to a ' . $type . '!'); } $unitPrice = trim($item->unitPrice); $qtyOrdered = trim($item->qtyOrdered); $totalPrice = trim($item->totalPrice); $itemDescription = trim($item->itemDescription); if (intval($item->active) === 1) { $totalPaymentDue += $totalPrice; if ($orderCloneFrom instanceof Order || !($orderItem = OrderItem::get($item->id)) instanceof OrderItem) { $orderItem = OrderItem::create($order, $product, $unitPrice, $qtyOrdered, $totalPrice, 0, null, $itemDescription); } else { $orderItem->setActive(intval($item->active))->setProduct($product)->setUnitPrice($unitPrice)->setQtyOrdered($qtyOrdered)->setTotalPrice($totalPrice)->setItemDescription($itemDescription)->save(); $existingSellingItems = SellingItem::getAllByCriteria('orderItemId = ?', array($orderItem->getId())); foreach ($existingSellingItems as $sellingItem) { //DELETING ALL SERIAL NUMBER BEFORE ADDING $sellingItem->setActive(false)->save(); } } $orderItem = OrderItem::get($orderItem->getId())->reCalMarginFromProduct()->resetCostNMarginFromKits()->save(); } else { if ($orderCloneFrom instanceof Order) { continue; } elseif (($orderItem = OrderItem::get($item->id)) instanceof OrderItem) { $orderItem->setActive(false)->save(); } } if (isset($item->serials) && count($item->serials) > 0) { foreach ($item->serials as $serialNo) { $orderItem->addSellingItem($serialNo)->save(); } } if ($shipped === true) { $orderItem->setIsPicked(true)->save(); } } if (isset($param->CallbackParameter->courierId)) { $totalShippingCost = 0; $courier = null; if (is_numeric($courierId = trim($param->CallbackParameter->courierId))) { $courier = Courier::get($courierId); if (!$courier instanceof Courier) { throw new Exception('Invalid Courier passed in!'); } $order->addInfo(OrderInfoType::ID_MAGE_ORDER_SHIPPING_METHOD, $courier->getName(), true); } else { $order->addInfo(OrderInfoType::ID_MAGE_ORDER_SHIPPING_METHOD, $courierId, true); } if (isset($param->CallbackParameter->totalShippingCost)) { $totalShippingCost = StringUtilsAbstract::getValueFromCurrency(trim($param->CallbackParameter->totalShippingCost)); $order->addInfo(OrderInfoType::ID_MAGE_ORDER_SHIPPING_COST, StringUtilsAbstract::getCurrency($totalShippingCost), true); } if ($shipped === true) { if (!$courier instanceof Courier) { $courier = Courier::get(Courier::ID_LOCAL_PICKUP); } Shippment::create($shippAddress, $courier, '', new UDate(), $order, ''); } } else { $courier = ''; $totalShippingCost = 0; } $totalPaymentDue += $totalShippingCost; $comments = isset($param->CallbackParameter->comments) ? trim($param->CallbackParameter->comments) : ''; $order = $order->addComment($comments, Comments::TYPE_SALES)->setTotalPaid($totalPaidAmount); if ($shipped === true) { $order->setStatus(OrderStatus::get(OrderStatus::ID_SHIPPED)); } $order->setTotalAmount($totalPaymentDue)->save(); if (isset($param->CallbackParameter->newMemo) && ($newMemo = trim($param->CallbackParameter->newMemo)) !== '') { $order->addComment($newMemo, Comments::TYPE_MEMO); } $results['item'] = $order->getJson(); if ($printItAfterSave === true) { $results['printURL'] = '/print/order/' . $order->getId() . '.html?pdf=1'; } $results['redirectURL'] = '/order/' . $order->getId() . '.html' . (trim($_SERVER['QUERY_STRING']) === '' ? '' : '?' . $_SERVER['QUERY_STRING']); Dao::commitTransaction(); } catch (Exception $ex) { Dao::rollbackTransaction(); $errors[] = $ex->getMessage(); } $param->ResponseData = StringUtilsAbstract::getJson($results, $errors); }
protected function lstCourier_Create() { $this->lstCourier = new QListBox($this, 'Courier'); $this->lstCourier->Name = QApplication::Translate('Courier'); $this->lstCourier->Required = true; $this->lstCourier->AddItem('- Select One -', null); $objCourierArray = Courier::LoadAll(QQ::Clause(QQ::OrderBy(QQN::Courier()->ShortDescription))); if ($objCourierArray) { foreach ($objCourierArray as $objCourier) { if ($objCourier->ActiveFlag) { $objListItem = new QListItem($objCourier->__toString(), $objCourier->CourierId); $this->lstCourier->AddItem($objListItem); } } } $this->lstCourier->AddItem('Other', null); }
protected function lstCourier_Create() { $this->lstCourier = new QListBox($this); $this->lstCourier->Name = QApplication::Translate('Courier'); $this->lstCourier->Required = true; //if (!$this->blnEditMode) $this->lstCourier->AddItem('- Select One -', null); $objCourierArray = Courier::LoadAll(QQ::Clause(QQ::OrderBy(QQN::Courier()->ShortDescription))); if ($objCourierArray) { foreach ($objCourierArray as $objCourier) { if ($objCourier->ActiveFlag) { $objListItem = new QListItem($objCourier->__toString(), $objCourier->CourierId); if ($this->objShipment->CourierId && $this->objShipment->CourierId == $objCourier->CourierId) { $objListItem->Selected = true; } $this->lstCourier->AddItem($objListItem); } } } if ($this->blnEditMode && !$this->objShipment->CourierId) { $this->lstCourier->AddItem('Other', null, true); } else { $this->lstCourier->AddItem('Other', null); } $this->lstCourier->TabIndex = 7; }
public function dtgCourier_Bind() { // Get Total Count b/c of Pagination $this->dtgCourier->TotalItemCount = Courier::CountAll(); $objClauses = array(); if ($objClause = $this->dtgCourier->OrderByClause) { array_push($objClauses, $objClause); } if ($objClause = $this->dtgCourier->LimitClause) { array_push($objClauses, $objClause); } $this->dtgCourier->DataSource = Courier::LoadAll($objClauses); }
/** * Refresh this MetaControl with Data from the local Shipment object. * @param boolean $blnReload reload Shipment from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objShipment->Reload(); } if ($this->lblShipmentId) { if ($this->blnEditMode) { $this->lblShipmentId->Text = $this->objShipment->ShipmentId; } } if ($this->txtShipmentNumber) { $this->txtShipmentNumber->Text = $this->objShipment->ShipmentNumber; } if ($this->lblShipmentNumber) { $this->lblShipmentNumber->Text = $this->objShipment->ShipmentNumber; } if ($this->lstTransaction) { $this->lstTransaction->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstTransaction->AddItem(QApplication::Translate('- Select One -'), null); } $objTransactionArray = Transaction::LoadAll(); if ($objTransactionArray) { foreach ($objTransactionArray as $objTransaction) { $objListItem = new QListItem($objTransaction->__toString(), $objTransaction->TransactionId); if ($this->objShipment->Transaction && $this->objShipment->Transaction->TransactionId == $objTransaction->TransactionId) { $objListItem->Selected = true; } $this->lstTransaction->AddItem($objListItem); } } } if ($this->lblTransactionId) { $this->lblTransactionId->Text = $this->objShipment->Transaction ? $this->objShipment->Transaction->__toString() : null; } if ($this->lstFromCompany) { $this->lstFromCompany->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstFromCompany->AddItem(QApplication::Translate('- Select One -'), null); } $objFromCompanyArray = Company::LoadAll(); if ($objFromCompanyArray) { foreach ($objFromCompanyArray as $objFromCompany) { $objListItem = new QListItem($objFromCompany->__toString(), $objFromCompany->CompanyId); if ($this->objShipment->FromCompany && $this->objShipment->FromCompany->CompanyId == $objFromCompany->CompanyId) { $objListItem->Selected = true; } $this->lstFromCompany->AddItem($objListItem); } } } if ($this->lblFromCompanyId) { $this->lblFromCompanyId->Text = $this->objShipment->FromCompany ? $this->objShipment->FromCompany->__toString() : null; } if ($this->lstFromContact) { $this->lstFromContact->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstFromContact->AddItem(QApplication::Translate('- Select One -'), null); } $objFromContactArray = Contact::LoadAll(); if ($objFromContactArray) { foreach ($objFromContactArray as $objFromContact) { $objListItem = new QListItem($objFromContact->__toString(), $objFromContact->ContactId); if ($this->objShipment->FromContact && $this->objShipment->FromContact->ContactId == $objFromContact->ContactId) { $objListItem->Selected = true; } $this->lstFromContact->AddItem($objListItem); } } } if ($this->lblFromContactId) { $this->lblFromContactId->Text = $this->objShipment->FromContact ? $this->objShipment->FromContact->__toString() : null; } if ($this->lstFromAddress) { $this->lstFromAddress->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstFromAddress->AddItem(QApplication::Translate('- Select One -'), null); } $objFromAddressArray = Address::LoadAll(); if ($objFromAddressArray) { foreach ($objFromAddressArray as $objFromAddress) { $objListItem = new QListItem($objFromAddress->__toString(), $objFromAddress->AddressId); if ($this->objShipment->FromAddress && $this->objShipment->FromAddress->AddressId == $objFromAddress->AddressId) { $objListItem->Selected = true; } $this->lstFromAddress->AddItem($objListItem); } } } if ($this->lblFromAddressId) { $this->lblFromAddressId->Text = $this->objShipment->FromAddress ? $this->objShipment->FromAddress->__toString() : null; } if ($this->lstToCompany) { $this->lstToCompany->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstToCompany->AddItem(QApplication::Translate('- Select One -'), null); } $objToCompanyArray = Company::LoadAll(); if ($objToCompanyArray) { foreach ($objToCompanyArray as $objToCompany) { $objListItem = new QListItem($objToCompany->__toString(), $objToCompany->CompanyId); if ($this->objShipment->ToCompany && $this->objShipment->ToCompany->CompanyId == $objToCompany->CompanyId) { $objListItem->Selected = true; } $this->lstToCompany->AddItem($objListItem); } } } if ($this->lblToCompanyId) { $this->lblToCompanyId->Text = $this->objShipment->ToCompany ? $this->objShipment->ToCompany->__toString() : null; } if ($this->lstToContact) { $this->lstToContact->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstToContact->AddItem(QApplication::Translate('- Select One -'), null); } $objToContactArray = Contact::LoadAll(); if ($objToContactArray) { foreach ($objToContactArray as $objToContact) { $objListItem = new QListItem($objToContact->__toString(), $objToContact->ContactId); if ($this->objShipment->ToContact && $this->objShipment->ToContact->ContactId == $objToContact->ContactId) { $objListItem->Selected = true; } $this->lstToContact->AddItem($objListItem); } } } if ($this->lblToContactId) { $this->lblToContactId->Text = $this->objShipment->ToContact ? $this->objShipment->ToContact->__toString() : null; } if ($this->lstToAddress) { $this->lstToAddress->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstToAddress->AddItem(QApplication::Translate('- Select One -'), null); } $objToAddressArray = Address::LoadAll(); if ($objToAddressArray) { foreach ($objToAddressArray as $objToAddress) { $objListItem = new QListItem($objToAddress->__toString(), $objToAddress->AddressId); if ($this->objShipment->ToAddress && $this->objShipment->ToAddress->AddressId == $objToAddress->AddressId) { $objListItem->Selected = true; } $this->lstToAddress->AddItem($objListItem); } } } if ($this->lblToAddressId) { $this->lblToAddressId->Text = $this->objShipment->ToAddress ? $this->objShipment->ToAddress->__toString() : null; } if ($this->lstCourier) { $this->lstCourier->RemoveAllItems(); $this->lstCourier->AddItem(QApplication::Translate('- Select One -'), null); $objCourierArray = Courier::LoadAll(); if ($objCourierArray) { foreach ($objCourierArray as $objCourier) { $objListItem = new QListItem($objCourier->__toString(), $objCourier->CourierId); if ($this->objShipment->Courier && $this->objShipment->Courier->CourierId == $objCourier->CourierId) { $objListItem->Selected = true; } $this->lstCourier->AddItem($objListItem); } } } if ($this->lblCourierId) { $this->lblCourierId->Text = $this->objShipment->Courier ? $this->objShipment->Courier->__toString() : null; } if ($this->txtTrackingNumber) { $this->txtTrackingNumber->Text = $this->objShipment->TrackingNumber; } if ($this->lblTrackingNumber) { $this->lblTrackingNumber->Text = $this->objShipment->TrackingNumber; } if ($this->calShipDate) { $this->calShipDate->DateTime = $this->objShipment->ShipDate; } if ($this->lblShipDate) { $this->lblShipDate->Text = sprintf($this->objShipment->ShipDate) ? $this->objShipment->__toString($this->strShipDateDateTimeFormat) : null; } if ($this->chkShippedFlag) { $this->chkShippedFlag->Checked = $this->objShipment->ShippedFlag; } if ($this->lblShippedFlag) { $this->lblShippedFlag->Text = $this->objShipment->ShippedFlag ? QApplication::Translate('Yes') : QApplication::Translate('No'); } if ($this->lstCreatedByObject) { $this->lstCreatedByObject->RemoveAllItems(); $this->lstCreatedByObject->AddItem(QApplication::Translate('- Select One -'), null); $objCreatedByObjectArray = UserAccount::LoadAll(); if ($objCreatedByObjectArray) { foreach ($objCreatedByObjectArray as $objCreatedByObject) { $objListItem = new QListItem($objCreatedByObject->__toString(), $objCreatedByObject->UserAccountId); if ($this->objShipment->CreatedByObject && $this->objShipment->CreatedByObject->UserAccountId == $objCreatedByObject->UserAccountId) { $objListItem->Selected = true; } $this->lstCreatedByObject->AddItem($objListItem); } } } if ($this->lblCreatedBy) { $this->lblCreatedBy->Text = $this->objShipment->CreatedByObject ? $this->objShipment->CreatedByObject->__toString() : null; } if ($this->calCreationDate) { $this->calCreationDate->DateTime = $this->objShipment->CreationDate; } if ($this->lblCreationDate) { $this->lblCreationDate->Text = sprintf($this->objShipment->CreationDate) ? $this->objShipment->__toString($this->strCreationDateDateTimeFormat) : null; } if ($this->lstModifiedByObject) { $this->lstModifiedByObject->RemoveAllItems(); $this->lstModifiedByObject->AddItem(QApplication::Translate('- Select One -'), null); $objModifiedByObjectArray = UserAccount::LoadAll(); if ($objModifiedByObjectArray) { foreach ($objModifiedByObjectArray as $objModifiedByObject) { $objListItem = new QListItem($objModifiedByObject->__toString(), $objModifiedByObject->UserAccountId); if ($this->objShipment->ModifiedByObject && $this->objShipment->ModifiedByObject->UserAccountId == $objModifiedByObject->UserAccountId) { $objListItem->Selected = true; } $this->lstModifiedByObject->AddItem($objListItem); } } } if ($this->lblModifiedBy) { $this->lblModifiedBy->Text = $this->objShipment->ModifiedByObject ? $this->objShipment->ModifiedByObject->__toString() : null; } if ($this->lblModifiedDate) { if ($this->blnEditMode) { $this->lblModifiedDate->Text = $this->objShipment->ModifiedDate; } } if ($this->lstShipmentCustomFieldHelper) { $this->lstShipmentCustomFieldHelper->RemoveAllItems(); $this->lstShipmentCustomFieldHelper->AddItem(QApplication::Translate('- Select One -'), null); $objShipmentCustomFieldHelperArray = ShipmentCustomFieldHelper::LoadAll(); if ($objShipmentCustomFieldHelperArray) { foreach ($objShipmentCustomFieldHelperArray as $objShipmentCustomFieldHelper) { $objListItem = new QListItem($objShipmentCustomFieldHelper->__toString(), $objShipmentCustomFieldHelper->ShipmentId); if ($objShipmentCustomFieldHelper->ShipmentId == $this->objShipment->ShipmentId) { $objListItem->Selected = true; } $this->lstShipmentCustomFieldHelper->AddItem($objListItem); } } // Because ShipmentCustomFieldHelper's ShipmentCustomFieldHelper is not null, if a value is already selected, it cannot be changed. if ($this->lstShipmentCustomFieldHelper->SelectedValue) { $this->lstShipmentCustomFieldHelper->Enabled = false; } else { $this->lstShipmentCustomFieldHelper->Enabled = true; } } if ($this->lblShipmentCustomFieldHelper) { $this->lblShipmentCustomFieldHelper->Text = $this->objShipment->ShipmentCustomFieldHelper ? $this->objShipment->ShipmentCustomFieldHelper->__toString() : null; } }
function parseXml($xml, $dataType) { $contragentUrl = "Company"; $array = array(); switch ($dataType) { case "customerOrder": $ordersForThisDateCounter = 0; $ordersValidForThisDateCounter = 0; $ordersWithValidContragentForThisDateCounter = 0; foreach ($xml->customerOrder as $customerOrder) { $isDeleted = false; foreach ($customerOrder->children() as $child) { if ($child->getName() == "deleted") { $isDeleted = true; } } if (!$isDeleted) { $ordersForThisDateCounter++; $newOrder = new CustomerOrder($customerOrder); if ($newOrder->areAllFieldsValid()) { $ordersValidForThisDateCounter++; $filterCompanyString = urlencode("uuid=" . $newOrder->getSourceAgentUuid()); $contragentData = getXmlFromMoysklad($contragentUrl, "?filter=" . $filterCompanyString); try { $contragentXml = new SimpleXmlElement($contragentData); $address = (string) $contragentXml->company->requisite["actualAddress"]; $contragentName = (string) $contragentXml->company["name"]; if (!empty($address)) { $ordersWithValidContragentForThisDateCounter++; $newOrder->setAddress($address); $newOrder->setContragentName($contragentName); $array[$newOrder->getUuid()] = $newOrder; $GLOBALS["numberOfOrders"]++; } } catch (Exception $e) { //echo "Выброшено исключение: ?filter=".$filterCompanyString."<br>"; } } } } $GLOBALS["ordersForThisDateCounter"] = $ordersForThisDateCounter; $GLOBALS["ordersValidForThisDateCounter"] = $ordersValidForThisDateCounter; $GLOBALS["ordersWithValidContragentForThisDateCounter"] = $ordersWithValidContragentForThisDateCounter; break; case "good": foreach ($xml->good as $good) { $newGood = new Good($good); $array[$newGood->getUuid()] = $newGood; } break; case "service": foreach ($xml->service as $service) { $newServiceUuid = (string) $service->uuid; $newServiceName = (string) $service["name"]; $array[$newServiceUuid] = $newServiceName; } break; case "courier": foreach ($xml->employee as $courier) { $newCourier = new Courier($courier); if ($newCourier->areAllFieldsValid() && $newCourier->getIsCourier() && $newCourier->getIsActive()) { $array[$newCourier->getUuid()] = $newCourier; } } break; case "warehouse": foreach ($xml->warehouse as $warehouse) { $newWarehouse = new Warehouse($warehouse); $array[$newWarehouse->getUuid()] = $newWarehouse; } break; } return $array; }
/** * updating the shipping details * * @param unknown $sender * @param unknown $param */ public function updateShippingDetails($sender, $params) { $result = $error = $shippingInfoArray = array(); try { Dao::beginTransaction(); if (!isset($params->CallbackParameter->order) || !($order = Order::getByOrderNo($params->CallbackParameter->order->orderNo)) instanceof Order) { throw new Exception('System Error: invalid order passed in!'); } if (!$order->getStatus() instanceof OrderStatus || trim($order->getStatus()->getId()) !== trim(OrderStatus::ID_PICKED)) { throw new Exception('System Error: Order [' . $order->getOrderNo() . '] Is Not is PICKED status. Current status is [' . ($order->getStatus() instanceof OrderStatus ? $order->getStatus()->getName() : 'NULL') . ']'); } if (intval($order->getPassPaymentCheck()) !== 1) { throw new Exception('Error: there is no payment or payments has been cancelled!'); } if (!isset($params->CallbackParameter->shippingInfo)) { throw new Exception('System Error: invalid Shipping Info Details passed in!'); } $shippingInfo = $params->CallbackParameter->shippingInfo; if (!($courier = Courier::get($shippingInfo->courierId)) instanceof Courier) { throw new Exception('Invalid Courier Id [' . $shippingInfo->courierId . '] provided'); } if (intval($order->getPassPaymentCheck()) !== 1) { throw new Exception('This ' . $order->getType() . ' has NOT pass payment check yet, please let the accounting department know before further actions!'); } $notifyCust = isset($shippingInfo->notifyCust) && intval($shippingInfo->notifyCust) === 1 ? true : false; //$companyName = $shippingInfo->companyName; $contactName = $shippingInfo->contactName; $contactNo = $shippingInfo->contactNo; $shippingAddress = Address::create(trim($shippingInfo->street), trim($shippingInfo->city), trim($shippingInfo->region), trim($shippingInfo->country), trim($shippingInfo->postCode), trim($contactName), trim($contactNo)); $shipment = Shippment::create($shippingAddress, $courier, trim($shippingInfo->conNoteNo), new UDate(), $order, $contactName, trim($contactNo), trim($shippingInfo->noOfCartons), '0', StringUtilsAbstract::getValueFromCurrency(trim($shippingInfo->actualShippingCost)), isset($shippingInfo->deliveryInstructions) ? trim($shippingInfo->deliveryInstructions) : ''); $order->setStatus(OrderStatus::get(OrderStatus::ID_SHIPPED))->save(); $result['shipment'] = $shipment->getJson(); //add shipment information if ($notifyCust === true && $order->getIsFromB2B() === true) { $templateName = trim($shipment->getCourier()->getId()) === trim(Courier::ID_LOCAL_PICKUP) ? 'local_pickup' : $order->getStatus()->getName(); $notificationMsg = trim(OrderNotificationTemplateControl::getMessage($templateName, $order)); if ($notificationMsg !== '') { B2BConnector::getConnector(B2BConnector::CONNECTOR_TYPE_SHIP, SystemSettings::getSettings(SystemSettings::TYPE_B2B_SOAP_WSDL), SystemSettings::getSettings(SystemSettings::TYPE_B2B_SOAP_USER), SystemSettings::getSettings(SystemSettings::TYPE_B2B_SOAP_KEY))->shipOrder($order, $shipment, array(), $notificationMsg, false, false); //push the status of the order to SHIPPed $emailToCustomer = trim($shipment->getCourier()->getId()) !== trim(Courier::ID_LOCAL_PICKUP); B2BConnector::getConnector(B2BConnector::CONNECTOR_TYPE_ORDER, SystemSettings::getSettings(SystemSettings::TYPE_B2B_SOAP_WSDL), SystemSettings::getSettings(SystemSettings::TYPE_B2B_SOAP_USER), SystemSettings::getSettings(SystemSettings::TYPE_B2B_SOAP_KEY))->changeOrderStatus($order, $order->getStatus()->getMageStatus(), $notificationMsg, $emailToCustomer); if ($emailToCustomer === true) { $order->addComment('An email notification contains shippment information has been sent to customer for: ' . $order->getStatus()->getName(), Comments::TYPE_SYSTEM); } } } Dao::commitTransaction(); } catch (Exception $ex) { Dao::rollbackTransaction(); $error[] = $ex->getMessage(); } $params->ResponseData = StringUtilsAbstract::getJson($result, $error); }
/** * Internally called method to assist with early binding of objects * on load methods. Can only early-bind references that this class owns in the database. * @param string $strParentAlias the alias of the parent (if any) * @param string $strAlias the alias of this object * @param array $objExpansionMap map of referenced columns to be immediately expanded via early-binding * @param QueryExpansion an already instantiated QueryExpansion object (used as a utility object to assist with object expansion) */ public static function ExpandQuery($strParentAlias, $strAlias, $objExpansionMap, QQueryExpansion $objQueryExpansion) { if ($strAlias) { $objQueryExpansion->AddFromItem(sprintf('LEFT JOIN `shipment` AS `%s__%s` ON `%s`.`%s` = `%s__%s`.`shipment_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`shipment_id` AS `%s__%s__shipment_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`shipment_number` AS `%s__%s__shipment_number`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`transaction_id` AS `%s__%s__transaction_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`from_company_id` AS `%s__%s__from_company_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`from_contact_id` AS `%s__%s__from_contact_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`from_address_id` AS `%s__%s__from_address_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`to_company_id` AS `%s__%s__to_company_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`to_contact_id` AS `%s__%s__to_contact_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`to_address_id` AS `%s__%s__to_address_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`courier_id` AS `%s__%s__courier_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`tracking_number` AS `%s__%s__tracking_number`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`ship_date` AS `%s__%s__ship_date`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`shipped_flag` AS `%s__%s__shipped_flag`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`created_by` AS `%s__%s__created_by`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`creation_date` AS `%s__%s__creation_date`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`modified_by` AS `%s__%s__modified_by`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`modified_date` AS `%s__%s__modified_date`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $strParentAlias = $strParentAlias . '__' . $strAlias; } if (is_array($objExpansionMap)) { foreach ($objExpansionMap as $strKey => $objValue) { switch ($strKey) { case 'transaction_id': try { Transaction::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'from_company_id': try { Company::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'from_contact_id': try { Contact::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'from_address_id': try { Address::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'to_company_id': try { Company::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'to_contact_id': try { Contact::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'to_address_id': try { Address::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'courier_id': try { Courier::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'created_by': try { UserAccount::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'modified_by': try { UserAccount::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } default: throw new QCallerException(sprintf('Unknown Object to Expand in %s: %s', $strParentAlias, $strKey)); } } } }
/** * Creating a courier * * @param string $name * @param string $connector * @param string $code * * @return Courier */ public static function create($name, $connector = 'CourierConn_Manual', $code = 'custom') { $item = new Courier(); return $item->setName(trim($name))->setConnector(trim($connector))->setCode(trim($code))->save(); }
protected function Form_PreRender() { $this->dtgCourier->TotalItemCount = Courier::CountAll(); if ($this->dtgCourier->TotalItemCount == 0) { $this->dtgCourier->ShowHeader = false; } else { $objClauses = array(); if ($objClause = $this->dtgCourier->OrderByClause) { array_push($objClauses, $objClause); } if ($objClause = $this->dtgCourier->LimitClause) { array_push($objClauses, $objClause); } $this->dtgCourier->DataSource = Courier::LoadAll($objClauses); $this->dtgCourier->ShowHeader = true; } }
public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) { if ($objObject->objCourier) { $objObject->objCourier = Courier::GetSoapObjectFromObject($objObject->objCourier, false); } else { if (!$blnBindRelatedObjects) { $objObject->intCourierId = null; } } if ($objObject->objCreatedByObject) { $objObject->objCreatedByObject = UserAccount::GetSoapObjectFromObject($objObject->objCreatedByObject, false); } else { if (!$blnBindRelatedObjects) { $objObject->intCreatedBy = null; } } if ($objObject->dttCreationDate) { $objObject->dttCreationDate = $objObject->dttCreationDate->__toString(QDateTime::FormatSoap); } if ($objObject->objModifiedByObject) { $objObject->objModifiedByObject = UserAccount::GetSoapObjectFromObject($objObject->objModifiedByObject, false); } else { if (!$blnBindRelatedObjects) { $objObject->intModifiedBy = null; } } return $objObject; }
<?php class Courier { public $name; public $home_country; public static function getCouriersByCountry($country) { return $country; } } $varun = Courier::getCouriersByCountry('australia'); echo $varun;