예제 #1
1
 public function StockCreationExample()
 {
     $metric = new Metric();
     $metric->name = 'Unit';
     $metric->symbol = 'U';
     $metric->save();
     //Now, create a category to store the inventory record under:
     $category = new Category();
     $category->name = 'VoIP';
     $category->save();
     $item = new Inventory();
     $item->metric_id = $metric->id;
     $item->category_id = $category->id;
     $item->name = 'SNOM Headset';
     $item->description = 'Very nice for the ear';
     $item->save();
     $location = new Location();
     $location->name = 'Snowball Small Stock Room';
     $location->save();
     $item->createStockOnLocation(2, $location);
     $item->createSku('PART1234');
     dd($item->sku_code);
     //$res = Inventory::findBySku(Input::get('sku'));
     //$item = Inventory::find(1);
     //dd($item);
     $supplier = new Supplier();
     //Mandatory fields
     $supplier->name = 'Miro Distribution';
     //Optional fields
     $supplier->address = 'Montague Gardens';
     $supplier->postal_code = '8000';
     $supplier->zip_code = '12345';
     $supplier->country = 'South Africa';
     $supplier->region = 'Western Cape';
     $supplier->city = 'Cape Town';
     $supplier->contact_title = 'Sales Rep';
     $supplier->contact_name = 'Mark Sparky';
     $supplier->contact_phone = '555 555-5555';
     $supplier->contact_fax = '555 555-5556';
     $supplier->contact_email = '*****@*****.**';
     $supplier->save();
     $item = Inventory::find(1);
     //$supplier = Supplier::find(1);
     $item->addSupplier($supplier);
 }
예제 #2
0
 public static function processDatafeed(Supplier $supplier, array $data)
 {
     $base = dirname(__FILE__);
     if (file_exists($file_name = $base . '/datafeed/' . strtolower($supplier->getName()) . '.php') === true) {
         require_once $file_name;
     }
     $class = ucfirst($supplier->getName()) . 'Connector';
     return $class::run($data);
 }
예제 #3
0
 /**
  * (non-PHPdoc)
  * @see DetailsPageAbstract::saveItem()
  */
 public function saveItem($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($param->CallbackParameter->id)) {
             throw new Exception('Invalid supplier ID passed in!');
         }
         $supplier = ($id = trim($param->CallbackParameter->id)) === '' ? new Supplier() : Supplier::get($id);
         if (!$supplier instanceof Supplier) {
             throw new Exception('Invalid supplier passed in!');
         }
         $contactName = trim($param->CallbackParameter->address->contactName);
         $contactNo = trim($param->CallbackParameter->address->contactNo);
         $street = trim($param->CallbackParameter->address->street);
         $city = trim($param->CallbackParameter->address->city);
         $region = trim($param->CallbackParameter->address->region);
         $postCode = trim($param->CallbackParameter->address->postCode);
         $country = trim($param->CallbackParameter->address->country);
         $address = $supplier->getAddress();
         $supplier->setName(trim($param->CallbackParameter->name))->setDescription(trim($param->CallbackParameter->description))->setContactNo(trim($param->CallbackParameter->contactNo))->setEmail(trim($param->CallbackParameter->email))->setAddress(Address::create($street, $city, $region, $country, $postCode, $contactName, $contactNo, $address))->save();
         $results['url'] = '/supplier/' . $supplier->getId() . '.html' . (isset($_REQUEST['blanklayout']) ? '?blanklayout=' . $_REQUEST['blanklayout'] : '');
         $results['item'] = $supplier->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage() . $ex->getTraceAsString();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
예제 #4
0
 /**
  * saveOrder
  *
  * @param unknown $sender
  * @param unknown $param
  *
  * @throws Exception
  *
  */
 public function saveOrder($sender, $param)
 {
     $results = $errors = array();
     $daoStart = false;
     try {
         Dao::beginTransaction();
         $daoStart = true;
         $supplier = Supplier::get(trim($param->CallbackParameter->supplier->id));
         if (!$supplier instanceof Supplier) {
             throw new Exception('Invalid Supplier passed in!');
         }
         $supplierContactName = trim($param->CallbackParameter->supplier->contactName);
         $supplierContactNo = trim($param->CallbackParameter->supplier->contactNo);
         $supplierEmail = trim($param->CallbackParameter->supplier->email);
         if (!empty($supplierContactName) && $supplierContactName !== $supplier->getContactName()) {
             $supplier->setContactName($supplierContactName);
         }
         if (!empty($supplierContactNo) && $supplierContactNo !== $supplier->getContactNo()) {
             $supplier->setContactNo($supplierContactNo);
         }
         if (!empty($supplierEmail) && $supplierEmail !== $supplier->getEmail()) {
             $supplier->setEmail($supplierEmail);
         }
         $supplier->save();
         $purchaseOrder = PurchaseOrder::create($supplier, trim($param->CallbackParameter->supplierRefNum), $supplierContactName, $supplierContactNo, StringUtilsAbstract::getValueFromCurrency(trim($param->CallbackParameter->shippingCost)), StringUtilsAbstract::getValueFromCurrency(trim($param->CallbackParameter->handlingCost)))->setTotalAmount(StringUtilsAbstract::getValueFromCurrency(trim($param->CallbackParameter->totalPaymentDue)))->setEta(trim($param->CallbackParameter->eta))->setStatus(PurchaseOrder::STATUS_NEW)->save()->addComment(trim($param->CallbackParameter->comments), Comments::TYPE_PURCHASING);
         foreach ($param->CallbackParameter->items as $item) {
             if (!($product = Product::get(trim($item->productId))) instanceof Product) {
                 throw new Exception('Invalid Product passed in!');
             }
             $purchaseOrder->addItem($product, StringUtilsAbstract::getValueFromCurrency(trim($item->unitPrice)), 0 - abs(intval(trim($item->qtyOrdered))));
         }
         if ($param->CallbackParameter->submitToSupplier === true) {
             $purchaseOrder->setStatus(PurchaseOrder::STATUS_ORDERED);
         }
         // For credit PO
         if (isset($param->CallbackParameter->type) && trim($param->CallbackParameter->type) === 'CREDIT') {
             $purchaseOrder->setIsCredit(true);
             if (isset($param->CallbackParameter->po) && ($fromPO = PurchaseOrder::get(trim($param->CallbackParameter->po->id))) instanceof PurchaseOrder) {
                 $purchaseOrder->setFromPO($fromPO);
             }
         }
         $purchaseOrder->save();
         $daoStart = false;
         Dao::commitTransaction();
         $results['item'] = $purchaseOrder->getJson();
         if (isset($param->CallbackParameter->confirmEmail) && trim($confirmEmail = trim($param->CallbackParameter->confirmEmail)) !== '') {
             $pdfFile = EntityToPDF::getPDF($purchaseOrder);
             $asset = Asset::registerAsset($purchaseOrder->getPurchaseOrderNo() . '.pdf', file_get_contents($pdfFile), Asset::TYPE_TMP);
             EmailSender::addEmail('*****@*****.**', $confirmEmail, 'BudgetPC Purchase Order:' . $purchaseOrder->getPurchaseOrderNo(), 'Please Find the attached PurchaseOrder(' . $purchaseOrder->getPurchaseOrderNo() . ') from BudgetPC.', array($asset));
             EmailSender::addEmail('*****@*****.**', '*****@*****.**', 'BudgetPC Purchase Order:' . $purchaseOrder->getPurchaseOrderNo(), 'Please Find the attached PurchaseOrder(' . $purchaseOrder->getPurchaseOrderNo() . ') from BudgetPC.', array($asset));
             $purchaseOrder->addComment('An email sent to "' . $confirmEmail . '" with the attachment: ' . $asset->getAssetId(), Comments::TYPE_SYSTEM);
         }
     } catch (Exception $ex) {
         if ($daoStart === true) {
             Dao::rollbackTransaction();
         }
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
예제 #5
0
 /**
  * (non-PHPdoc)
  * @see CRUDPageAbstract::_getEndJs()
  */
 protected function _getEndJs()
 {
     $manufactureArray = $supplierArray = $statuses = $productCategoryArray = array();
     foreach (Manufacturer::getAll() as $os) {
         $manufactureArray[] = $os->getJson();
     }
     foreach (Supplier::getAll() as $os) {
         $supplierArray[] = $os->getJson();
     }
     foreach (ProductStatus::getAll() as $os) {
         $statuses[] = $os->getJson();
     }
     foreach (ProductCategory::getAll() as $os) {
         $productCategoryArray[] = $os->getJson();
     }
     $js = parent::_getEndJs();
     if (($product = Product::get($this->Request['id'])) instanceof Product) {
         $js .= "\$('searchPanel').hide();";
         $js .= "pageJs._singleProduct = true;";
     }
     $js .= 'pageJs._loadManufactures(' . json_encode($manufactureArray) . ')';
     $js .= '._loadSuppliers(' . json_encode($supplierArray) . ')';
     $js .= '._loadCategories(' . json_encode($productCategoryArray) . ')';
     $js .= '._loadProductStatuses(' . json_encode($statuses) . ')';
     $js .= "._loadChosen()";
     $js .= "._bindSearchKey()";
     $js .= ".setCallbackId('priceMatching', '" . $this->priceMatchingBtn->getUniqueID() . "')";
     $js .= ".setCallbackId('toggleActive', '" . $this->toggleActiveBtn->getUniqueID() . "')";
     $js .= ".getResults(true, " . $this->pageSize . ");";
     return $js;
 }
예제 #6
0
 public function getTemplateVarSitemap()
 {
     $pages = [];
     $catalog_mode = Configuration::isCatalogMode();
     $cms = CMSCategory::getRecurseCategory($this->context->language->id, 1, 1, 1);
     foreach ($cms['cms'] as $p) {
         $pages[] = ['id' => 'cms-page-' . $p['id_cms'], 'label' => $p['meta_title'], 'url' => $this->context->link->getCMSLink(new CMS($p['id_cms']))];
     }
     $pages[] = ['id' => 'stores-page', 'label' => $this->trans('Our stores', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('stores')];
     $pages[] = ['id' => 'contact-page', 'label' => $this->trans('Contact us', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('contact')];
     $pages[] = ['id' => 'sitemap-page', 'label' => $this->trans('Sitemap', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('sitemap')];
     $pages[] = ['id' => 'login-page', 'label' => $this->trans('Log in', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('authentication')];
     $pages[] = ['id' => 'register-page', 'label' => $this->trans('Create new account', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('authentication')];
     $catalog = ['new-product' => ['id' => 'new-product-page', 'label' => $this->trans('New products', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('new-products')]];
     if ($catalog_mode && Configuration::get('PS_DISPLAY_BEST_SELLERS')) {
         $catalog['best-sales'] = ['id' => 'best-sales-page', 'label' => $this->trans('Best sellers', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('best-sales')];
         $catalog['prices-drop'] = ['id' => 'prices-drop-page', 'label' => $this->trans('Price drop', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('prices-drop')];
     }
     if (Configuration::get('PS_DISPLAY_SUPPLIERS')) {
         $manufacturers = Manufacturer::getLiteManufacturersList($this->context->language->id, 'sitemap');
         $catalog['manufacturer'] = ['id' => 'manufacturer-page', 'label' => $this->trans('Manufacturers', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('manufacturer'), 'children' => $manufacturers];
         $suppliers = Supplier::getLiteSuppliersList($this->context->language->id, 'sitemap');
         $catalog['supplier'] = ['id' => 'supplier-page', 'label' => $this->trans('Suppliers', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('supplier'), 'children' => $suppliers];
     }
     $categories = Category::getRootCategory()->recurseLiteCategTree(0, 0, null, null, 'sitemap');
     $catalog['category'] = ['id' => 'category-page', 'label' => $this->trans('Categories', array(), 'Shop.Theme.Catalog'), 'url' => '#', 'children' => $categories['children']];
     $sitemap = [['id' => 'page-page', 'label' => $this->trans('Pages', array(), 'Shop.Theme'), 'url' => '#', 'children' => $pages], ['id' => 'catalog-page', 'label' => $this->trans('Catalog', array(), 'Shop.Theme'), 'url' => '#', 'children' => $catalog]];
     return $sitemap;
 }
 /**
  * @return null|object|Supplier
  * get singleton instance
  */
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new Supplier();
     }
     return self::$instance;
 }
 public function renderForm()
 {
     if (!$this->object->id) {
         $this->object->price = -1;
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Catalog price rules'), 'icon' => 'icon-dollar'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'maxlength' => 32, 'required' => true, 'hint' => $this->l('Forbidden characters') . ' <>;=#{}'), array('type' => 'select', 'label' => $this->l('Shop'), 'name' => 'shop_id', 'options' => array('query' => Shop::getShops(), 'id' => 'id_shop', 'name' => 'name'), 'condition' => Shop::isFeatureActive(), 'default_value' => Shop::getContextShopID()), array('type' => 'select', 'label' => $this->l('Currency'), 'name' => 'id_currency', 'options' => array('query' => array_merge(array(0 => array('id_currency' => 0, 'name' => $this->l('All currencies'))), Currency::getCurrencies()), 'id' => 'id_currency', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'options' => array('query' => array_merge(array(0 => array('id_country' => 0, 'name' => $this->l('All countries'))), Country::getCountries((int) $this->context->language->id)), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Group'), 'name' => 'id_group', 'options' => array('query' => array_merge(array(0 => array('id_group' => 0, 'name' => $this->l('All groups'))), Group::getGroups((int) $this->context->language->id)), 'id' => 'id_group', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('From quantity'), 'name' => 'from_quantity', 'maxlength' => 10, 'required' => true), array('type' => 'text', 'label' => $this->l('Price (tax excl.)'), 'name' => 'price', 'disabled' => $this->object->price == -1 ? 1 : 0, 'maxlength' => 10, 'suffix' => $this->context->currency->getSign('right')), array('type' => 'checkbox', 'name' => 'leave_bprice', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Leave base price'), 'val' => '1', 'checked' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'datetime', 'label' => $this->l('From'), 'name' => 'from'), array('type' => 'datetime', 'label' => $this->l('To'), 'name' => 'to'), array('type' => 'select', 'label' => $this->l('Reduction type'), 'name' => 'reduction_type', 'options' => array('query' => array(array('reduction_type' => 'amount', 'name' => $this->l('Amount')), array('reduction_type' => 'percentage', 'name' => $this->l('Percentage'))), 'id' => 'reduction_type', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Reduction with or without taxes'), 'name' => 'reduction_tax', 'align' => 'center', 'options' => array('query' => array(array('lab' => $this->l('Tax included'), 'val' => 1), array('lab' => $this->l('Tax excluded'), 'val' => 0)), 'id' => 'val', 'name' => 'lab')), array('type' => 'text', 'label' => $this->l('Reduction'), 'name' => 'reduction', 'required' => true)), 'submit' => array('title' => $this->l('Save')));
     if (($value = $this->getFieldValue($this->object, 'price')) != -1) {
         $price = number_format($value, 6);
     } else {
         $price = '';
     }
     $this->fields_value = array('price' => $price, 'from_quantity' => ($value = $this->getFieldValue($this->object, 'from_quantity')) ? $value : 1, 'reduction' => number_format(($value = $this->getFieldValue($this->object, 'reduction')) ? $value : 0, 6), 'leave_bprice_on' => $price ? 0 : 1);
     $attribute_groups = array();
     $attributes = Attribute::getAttributes((int) $this->context->language->id);
     foreach ($attributes as $attribute) {
         if (!isset($attribute_groups[$attribute['id_attribute_group']])) {
             $attribute_groups[$attribute['id_attribute_group']] = array('id_attribute_group' => $attribute['id_attribute_group'], 'name' => $attribute['attribute_group']);
         }
         $attribute_groups[$attribute['id_attribute_group']]['attributes'][] = array('id_attribute' => $attribute['id_attribute'], 'name' => $attribute['name']);
     }
     $features = Feature::getFeatures((int) $this->context->language->id);
     foreach ($features as &$feature) {
         $feature['values'] = FeatureValue::getFeatureValuesWithLang((int) $this->context->language->id, $feature['id_feature'], true);
     }
     $this->tpl_form_vars = array('manufacturers' => Manufacturer::getManufacturers(), 'suppliers' => Supplier::getSuppliers(), 'attributes_group' => $attribute_groups, 'features' => $features, 'categories' => Category::getSimpleCategories((int) $this->context->language->id), 'conditions' => $this->object->getConditions(), 'is_multishop' => Shop::isFeatureActive());
     return parent::renderForm();
 }
 /**
  * Contains the testing sample data for the ReceiptController.
  *
  * @return void
  */
 public function setVariables()
 {
     // Initial sample storage data
     $this->input = array('commodity' => Commodity::find(1)->id, 'supplier' => Supplier::find(1)->id, 'quantity' => '200', 'batch_no' => '4535', 'expiry_date' => '2015-07-17');
     // Edition sample data
     $this->inputUpdate = array('commodity' => Commodity::find(1)->id, 'supplier' => Supplier::find(1)->id, 'quantity' => '200', 'batch_no' => '4535', 'expiry_date' => '2015-07-17');
 }
예제 #10
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $receipt = Receipt::find($id);
     $suppliers = Supplier::all()->lists('name', 'id');
     $commodities = Commodity::all()->lists('name', 'id');
     return View::make('receipt.edit')->with('receipt', $receipt)->with('commodities', $commodities)->with('suppliers', $suppliers);
 }
예제 #11
0
 function hookDisplayLeftColumn($params)
 {
     $id_lang = (int) Context::getContext()->language->id;
     if (!$this->isCached('blocksupplier.tpl', $this->getCacheId())) {
         $this->smarty->assign(array('suppliers' => Supplier::getSuppliers(false, $id_lang), 'link' => $this->context->link, 'text_list' => Configuration::get('SUPPLIER_DISPLAY_TEXT'), 'text_list_nb' => Configuration::get('SUPPLIER_DISPLAY_TEXT_NB'), 'form_list' => Configuration::get('SUPPLIER_DISPLAY_FORM'), 'display_link_supplier' => Configuration::get('PS_DISPLAY_SUPPLIERS')));
     }
     return $this->display(__FILE__, 'blocksupplier.tpl', $this->getCacheId());
 }
예제 #12
0
파일: test.php 프로젝트: larryu/magento-b2b
function updateProduct($pro, $fileName, $line)
{
    $clientScript = CatelogConnector::getConnector(B2BConnector::CONNECTOR_TYPE_CATELOG, getWSDL(), 'B2BUser', 'B2BUser');
    try {
        $transStarted = false;
        try {
            Dao::beginTransaction();
        } catch (Exception $e) {
            $transStarted = true;
        }
        $sku = trim($pro['sku']);
        $product = Product::getBySku($pro['sku']);
        $mageId = trim($pro['product_id']);
        $name = trim($pro['name']);
        $short_description = trim($pro['short_description']);
        $description = trim($pro['description']);
        $weight = trim($pro['weight']);
        $statusId = trim($pro['status']);
        $price = trim($pro['price']);
        $specialPrice = trim($pro['special_price']);
        $specialPrice_From = trim($pro['special_from_date']) === '' ? trim($pro['special_from_date']) : null;
        $specialPrice_To = trim($pro['special_to_date']) === '' ? trim($pro['special_to_date']) : null;
        $supplierName = trim($pro['supplier']);
        $attributeSet = ProductAttributeSet::get(trim($pro['attributeSetId']));
        if (!$product instanceof Product) {
            $product = Product::create($sku, $name);
        }
        $asset = ($assetId = trim($product->getFullDescAssetId())) === '' || !($asset = Asset::getAsset($assetId)) instanceof Asset ? Asset::registerAsset('full_desc_' . $sku, $description, Asset::TYPE_PRODUCT_DEC) : $asset;
        $product->setName($name)->setMageId($mageId)->setAttributeSet($attributeSet)->setShortDescription($short_description)->setFullDescAssetId(trim($asset->getAssetId()))->setIsFromB2B(true)->setStatus(ProductStatus::get($statusId))->setSellOnWeb(true)->setManufacturer($clientScript->getManufacturerName(trim($pro['manufacturer'])))->save()->clearAllPrice()->addPrice(ProductPriceType::get(ProductPriceType::ID_RRP), $price)->addInfo(ProductInfoType::ID_WEIGHT, $weight);
        if ($specialPrice !== '') {
            $product->addPrice(ProductPriceType::get(ProductPriceType::ID_CASUAL_SPECIAL), $specialPrice, $specialPrice_From, $specialPrice_To);
        }
        if ($supplierName !== '') {
            $product->addSupplier(Supplier::create($supplierName, $supplierName, true));
        }
        if (isset($pro['categories']) && count($pro['categories']) > 0) {
            $product->clearAllCategory();
            foreach ($pro['categories'] as $cateMageId) {
                if (!($category = ProductCategory::getByMageId($cateMageId)) instanceof ProductCategory) {
                    continue;
                }
                $product->addCategory($category);
            }
        }
        if ($transStarted === false) {
            Dao::commitTransaction();
        }
        //TODO remove the file
        removeLineFromFile($fileName, $line);
        echo $product->getId() . " => done! \n";
    } catch (Exception $ex) {
        if ($transStarted === false) {
            Dao::rollbackTransaction();
        }
        throw $ex;
    }
}
 /**
  * Method postProcess() : add or update supplier object
  *
  * @module now_seo_links
  * @return object Supplier
  *
  * @see AdminSuppliersControllerCore::postProcess()
  */
 public function postProcess()
 {
     $aShops = array_keys(Tools::getValue('checkBoxShopAsso_supplier', array()));
     // Check if name already exist
     if (Supplier::nameIsAlreadyUsed(Tools::getValue('id_supplier'), Tools::getValue('name'), $aShops)) {
         $this->errors[] = Tools::displayError('Ce nom de fournisseur existe déjà et ne peut être utilisé une nouvelle fois.');
     }
     return parent::postProcess();
 }
 /**
  * Tests the update function in the SupplierController
  * @depends testStore
  * @param void
  * @return void
  */
 public function testDelete()
 {
     $this->be(User::first());
     $this->runStore($this->input);
     $supplier = new SupplierController();
     $supplier->delete(1);
     $supplierDeleted = Supplier::withTrashed()->find(1);
     $this->assertNotNull($supplierDeleted->deleted_at);
 }
예제 #15
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $del = Supplier::find($id)->delete();
     if ($del) {
         echo "Your Item Deleted";
     } else {
         echo "Not Found or Already Deleted";
     }
 }
 /**
  * Checks if the parameter is a valid supplier id
  * @param $id int
  * @return Supplier object if $id is found, otherwise false
  */
 private function __checkExistence($id)
 {
     if (!is_null($id) && $id != '') {
         $supplier = Supplier::withTrashed()->find($id);
         if (is_null($supplier)) {
             return false;
         }
         return $supplier;
     }
     return false;
 }
 public function SupplierAndItemInfo()
 {
     App::uses("Supplier", "Inventory.Model");
     App::import("Model", "Inventory.Item");
     $supplierModel = new Supplier();
     $itemModel = new Item();
     $supplierModel->recursive = 0;
     $suppliers = $supplierModel->find("all");
     $tmp_suplliers = array();
     foreach ($suppliers as $key => $supplier) {
         $tmp_suplliers[$supplier['Supplier']['id']]['name'] = $supplier['Supplier']['name'];
         $tmp_suplliers[$supplier['Supplier']['id']]['email'] = $supplier['Supplier']['email'];
         $tmp_suplliers[$supplier['Supplier']['id']]['gst'] = $supplier['Supplier']['gst_rate'];
         $tmp_suplliers[$supplier['Supplier']['id']]['pst'] = $supplier['Supplier']['pst_rate'];
         $tmp_suplliers[$supplier['Supplier']['id']]['item'] = $itemModel->find("list", array("fields" => array("id_plus_item"), 'conditions' => array('supplier_id' => $supplier['Supplier']['id'])));
         $tmp_suplliers[$supplier['Supplier']['id']]['address'] = $this->address_format($supplier['Supplier']['address'], $supplier['Supplier']['city'], $supplier['Supplier']['province'], $supplier['Supplier']['country'], $supplier['Supplier']['postal_code']);
         $tmp_suplliers[$supplier['Supplier']['id']]['phone'] = $this->phone_format($supplier['Supplier']['phone'], $supplier['Supplier']['phone_ext'], $supplier['Supplier']['cell'], $supplier['Supplier']['fax_number']);
     }
     return $tmp_suplliers;
 }
예제 #18
0
 public function run()
 {
     // Initialize empty array
     $supplier = array();
     $date = new DateTime();
     $supplier[] = array('name' => 'New Egg', 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'));
     $supplier[] = array('name' => 'Microsoft', 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'));
     // Delete all the old data
     DB::table('suppliers')->truncate();
     // Insert the new posts
     Supplier::insert($supplier);
 }
 public function postLoadSupplierProducts()
 {
     if (Request::ajax()) {
         $post = Input::all();
         $supplier = Supplier::find($post['suppliersId']);
         if (!is_null($supplier)) {
             $products = $supplier->products()->orderBy('name')->get();
             return View::make('products.select')->with('products', $products)->render();
         } else {
             return Form::select('product', array('' => ' - Seleccione - '), null, array('class' => 'form-control', 'id' => 'product'));
         }
     }
 }
예제 #20
0
 public function execute($job, $data)
 {
     $sup = Supplier::forge($data['id']);
     switch (\Arr::get($data, 'method', 'change')) {
         case 'update':
             $sup->update(\Arr::get($data, 'cached', false), \Arr::get($data, 'force', false));
             break;
         case 'change':
         default:
             $sup->change(\Arr::get($data, 'cached', false));
             break;
     }
 }
예제 #21
0
 /**
  * This method stores the necessary bits of data in this object.
  *
  * @param Channel $chan
  * @param array $updateData
  * @return void
  * @throws CouldNotUpdate
  * @throws NoSupplier
  */
 protected function unpackMessageUpdate(Channel $chan, array $updateData)
 {
     // This is the JSON message from the tree node, stored as an array:
     $this->updateMessage = $updateData;
     if ($this->isPackageUpdate() || $this->isAirshipUpdate()) {
         // These aren't signed for updating the tree.
         return;
     }
     // We need a precise format:
     $dateGen = (new \DateTime($this->stored['date_generated']))->format(\AIRSHIP_DATE_FORMAT);
     $messageToSign = ['action' => $this->action, 'date_generated' => $dateGen, 'public_key' => $updateData['public_key'], 'supplier' => $updateData['supplier'], 'type' => $updateData['type']];
     try {
         $this->supplier = $this->loadSupplier($chan, $updateData);
     } catch (NoSupplier $ex) {
         if (!$this->isNewSupplier) {
             throw $ex;
         }
     }
     // If this isn't a new supplier, we need to verify the key
     if ($this->isNewSupplier) {
         return;
     }
     if ($updateData['master'] === null) {
         throw new CouldNotUpdate(\__('The master data is NULL, but the supplier exists.'));
     }
     $master = \json_decode($updateData['master'], true);
     foreach ($this->supplier->getSigningKeys() as $supKey) {
         // Yes, this is (in fact) a SignaturePublicKey:
         if (IDE_HACKS) {
             $supKey['key'] = new SignaturePublicKey();
         }
         if ($supKey['type'] !== 'master') {
             continue;
         }
         $pub = \Sodium\bin2hex($supKey['key']->getRawKeyMaterial());
         // Is this the key we're looking for?
         if (\hash_equals($pub, $master['public_key'])) {
             // Store the public key
             $this->supplierMasterKeyUsed = $supKey['key'];
             break;
         }
     }
     if (empty($this->supplierMasterKeyUsed)) {
         throw new CouldNotUpdate(\__('The provided public key does not match any known master key.'));
     }
     $encoded = \json_encode($messageToSign);
     if (!Asymmetric::verify($encoded, $this->supplierMasterKeyUsed, $master['signature'])) {
         throw new CouldNotUpdate(\__('Invalid signature for this master key.'));
     }
 }
예제 #22
0
 public static function generateId()
 {
     $supplier = Supplier::orderBy('supplierID', 'DESC')->get()->first();
     $supplierId = $supplier->supplierID;
     $supplierId = substr($supplierId, 4);
     $newId = (int) $supplierId;
     $newId++;
     $newIdString = (string) $newId;
     $newIdString = "000000" . $newIdString;
     if (strlen($newIdString) > 3) {
         $newIdString = substr($newIdString, strlen($newIdString) - 3);
     }
     $newIdString = "SU" . $newIdString;
     return $newIdString;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     $rules = array("supplierId" => "required", "supplierName" => "required", "firstAddress" => "required", "secondAddress" => "required", "area" => "required", "region" => "required", "supplierPhone" => "required|numeric", "supplierFax" => "required|numeric", "supplierEmail" => "required|email", "supplierContact" => "required", "supplierMobile" => "required|numeric");
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('/supplier/create')->withErrors($validator);
     }
     //
     $supplier = new Supplier();
     $supplier->supplierID = Input::get('supplierId');
     $supplier->supplierName = Input::get('supplierName');
     $supplier->supplierAddress1 = Input::get('firstAddress');
     $supplier->supplierAddress2 = Input::get('secondAddress');
     $supplier->areaID = Input::get("area");
     $supplier->regionID = Input::get("region");
     $supplier->supplierPhone = Input::get("supplierPhone");
     $supplier->supplierFax = Input::get("supplierFax");
     $supplier->supplierEmail = Input::get("supplierEmail");
     $supplier->supplierContact = Input::get("supplierContact");
     $supplier->supplierMobile = Input::get("supplierMobile");
     $supplier->save();
     return Redirect::to('/supplier');
 }
예제 #24
0
 public function initContent()
 {
     parent::initContent();
     if (isset($this->context->cookie->id_compare)) {
         $this->context->smarty->assign('compareProducts', CompareProduct::getCompareProducts((int) $this->context->cookie->id_compare));
     }
     $this->productSort();
     // Product sort must be called before assignProductList()
     $this->assignScenes();
     $this->assignSubcategories();
     if ($this->category->id != 1) {
         $this->assignProductList();
     }
     $this->context->smarty->assign(array('category' => $this->category, 'products' => isset($this->cat_products) && $this->cat_products ? $this->cat_products : null, 'id_category' => (int) $this->category->id, 'id_category_parent' => (int) $this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name), 'path' => Tools::getPath($this->category->id), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize('category'), 'mediumSize' => Image::getSize('medium'), 'thumbSceneSize' => Image::getSize('thumb_scene'), 'homeSize' => Image::getSize('home'), 'allow_oosp' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers()));
     $this->setTemplate(_PS_THEME_DIR_ . 'category.tpl');
 }
 public function get($id = null)
 {
     $search = Input::get('search');
     if (!is_null($search)) {
         $supplierOrders = SupplierOrder::select('supplier_orders.*')->join('suppliers', 'suppliers.id', '=', 'supplier_orders.suppliers_id')->where('suppliers.name', 'like', '%' . $search . '%')->orWhere('code', 'like', '%' . $search . '%')->orderBy('supplier_orders.created_at', 'DESC')->paginate(15);
     } else {
         $supplierOrders = SupplierOrder::where('status', 'generated')->orderBy('created_at', 'DESC')->paginate(15);
     }
     $selectedSupplierOrder = self::__checkExistence($id);
     if (!$selectedSupplierOrder) {
         $selectedSupplierOrder = new SupplierOrder();
     }
     $products = $selectedSupplierOrder->products->toArray();
     $suppliers = Supplier::orderBy('name')->get()->lists('name', 'id');
     return View::make('supplierOrders.main')->with('id', $id)->with('selectedSupplierOrder', $selectedSupplierOrder)->with('products', $products)->with('suppliers', $suppliers)->with('search', $search)->with('supplierOrders', $supplierOrders);
 }
예제 #26
0
 public function getNum($code)
 {
     switch ($code) {
         case 1:
             $rows = Commodity::model()->findAll();
             $heading = 'commodity';
             $count = count($rows);
             break;
         case 2:
             $rows = Category::model()->findAll();
             $heading = 'category';
             $count = count($rows);
             break;
         case 3:
             $rows = Supplier::model()->findAll();
             $heading = 'supplier';
             $count = count($rows);
             break;
         case 4:
             $rows = User::model()->findAll();
             $heading = 'user';
             $count = count($rows);
             break;
         case 5:
             $rows = Allocate::model()->findAll();
             $heading = 'allocate';
             $count = count($rows);
             break;
     }
     $content = '<b style="class:circle">' . $count . '</b><br/>';
     $i = 2;
     if ($code != 5) {
         foreach ($rows as $r) {
             $content .= $r['name'] . '<br/>';
             --$i;
             if ($i <= 0) {
                 break;
             }
         }
         while ($i != 0) {
             $content .= '<br/>';
             --$i;
         }
         $content .= '<p style="display:inline;text-align:right"><i><a href="http://localhost/asset_management/index.php/' . $heading . '/admin">View All</a></i></p><br/>';
     }
     return $content;
 }
예제 #27
0
 public function run()
 {
     /*$faker = Faker::create();
     
     		foreach(range(1, 10) as $index)
     		{
     			Supplier::create([
     
     			]);
     		}*/
     Supplier::create(['name' => '杨一', 'short_name' => 'YY', 'type' => 0, 'mobile' => '13588100379', 'telephone' => '', 'mail' => '', 'url' => '', 'qq' => '', 'wechat' => '', 'province' => 1, 'city' => 1, 'district' => 1, 'street' => '绍兴柯桥119当铺', 'address' => '绍兴柯桥119当铺', 'postcode' => '310022', 'acreage' => '', 'company' => '', 'amount' => '', 'output' => '', 'bank' => '', 'bank_address' => '', 'account_no' => '', 'account_name' => '', 'audit_status' => 2]);
     Supplier::create(['name' => '杨二', 'short_name' => 'YE', 'type' => 0, 'mobile' => '13588100377', 'telephone' => '', 'mail' => '', 'url' => '', 'qq' => '', 'wechat' => '', 'province' => 1, 'city' => 1, 'district' => 1, 'street' => '绍兴柯桥117当铺', 'address' => '绍兴柯桥117当铺', 'postcode' => '310022', 'acreage' => '', 'company' => '', 'amount' => '', 'output' => '', 'bank' => '', 'bank_address' => '', 'account_no' => '', 'account_name' => '', 'audit_status' => 2]);
     Supplier::create(['name' => '杨三', 'short_name' => 'YS', 'type' => 0, 'mobile' => '13588100378', 'telephone' => '', 'mail' => '', 'url' => '', 'qq' => '', 'wechat' => '', 'province' => 1, 'city' => 1, 'district' => 1, 'street' => '绍兴柯桥118当铺', 'address' => '绍兴柯桥118当铺', 'postcode' => '310022', 'acreage' => '', 'company' => '', 'amount' => '', 'output' => '', 'bank' => '', 'bank_address' => '', 'account_no' => '', 'account_name' => '', 'audit_status' => 2]);
     Supplier::create(['name' => '杨学弟', 'short_name' => 'YXD', 'type' => 0, 'mobile' => '13588100375', 'telephone' => '', 'mail' => '', 'url' => '', 'qq' => '', 'wechat' => '', 'province' => 1, 'city' => 1, 'district' => 1, 'street' => '绍兴柯桥119当铺', 'address' => '绍兴柯桥119当铺', 'postcode' => '310022', 'acreage' => '', 'company' => '', 'amount' => '', 'output' => '', 'bank' => '', 'bank_address' => '', 'account_no' => '', 'account_name' => '', 'audit_status' => 2]);
     Supplier::create(['name' => '冬雪敏', 'short_name' => 'DXM', 'type' => 0, 'mobile' => '13588100374', 'telephone' => '', 'mail' => '', 'url' => '', 'qq' => '', 'wechat' => '', 'province' => 1, 'city' => 1, 'district' => 1, 'street' => '绍兴柯桥117当铺', 'address' => '绍兴柯桥117当铺', 'postcode' => '310022', 'acreage' => '', 'company' => '', 'amount' => '', 'output' => '', 'bank' => '', 'bank_address' => '', 'account_no' => '', 'account_name' => '', 'audit_status' => 2]);
     Supplier::create(['name' => '周小龙', 'short_name' => 'ZXL', 'type' => 0, 'mobile' => '13588100373', 'telephone' => '', 'mail' => '', 'url' => '', 'qq' => '', 'wechat' => '', 'province' => 1, 'city' => 1, 'district' => 1, 'street' => '绍兴柯桥118当铺', 'address' => '绍兴柯桥118当铺', 'postcode' => '310022', 'acreage' => '', 'company' => '', 'amount' => '', 'output' => '', 'bank' => '', 'bank_address' => '', 'account_no' => '', 'account_name' => '', 'audit_status' => 2]);
 }
예제 #28
0
 public function products()
 {
     $flash_string = '';
     if (Session::exists('account')) {
         $flash_string = Session::flash('account');
     }
     $user = new User();
     if ($user->isLoggedIn()) {
         //load database content
         $units = Unit::toArray();
         $products = Product::toArray();
         $suppliers = Supplier::toArray();
         $this->view('account/products', ['products' => json_encode($products), 'units' => json_encode($units), 'suppliers' => json_encode($suppliers), 'register' => true, 'loggedIn' => 1, 'flash' => $flash_string, 'name' => $user->data()->name, 'page_name' => 'Products', 'user_id' => $user->data()->id]);
     } else {
         Session::flash('home', 'You have been logged out, please log back in');
         Redirect::to('home');
     }
 }
 public function getIndex()
 {
     $edate = Supplierformdate::where('event', '=', Session::get('event'))->first();
     $currdate = strtotime(date('Y-m-d'));
     $evdate = strtotime($edate->opendate);
     $diff = abs(($currdate - $evdate) / (60 * 60 * 24));
     //dd($diff);
     if ($currdate >= $evdate) {
         $userdetails = array('name' => Auth::user()->name, 'event' => Auth::user()->event);
         $suppliers = Supplier::where('event', '=', Session::get('event'))->with(array('supplierranks' => function ($query) {
             $query->where('userid', '=', Session::get('userid'));
         }))->get();
         // $suppliers = Supplier::where('event','=',Session::get('event'))->with('supplierranks')->get()->sortBy('order');
         // $suppliers = Supplier::all()->sortBy('order');
         return View::make('rankingform.rankingform')->with(array('userdetails' => $userdetails, 'suppliers' => $suppliers));
     } else {
         $opendate = date('d-M-Y', $evdate);
         return View::make('rankingform.rankingformnotavailable')->with('opendate', $opendate);
     }
 }
예제 #30
0
 /**
  * Resets all references to other model objects or collections of model objects.
  *
  * This method is a user-space workaround for PHP's inability to garbage collect
  * objects with circular references (even in PHP 5.3). This is currently necessary
  * when using Propel in certain daemon or large-volume/high-memory operations.
  *
  * @param boolean $deep Whether to also clear the references on all referrer objects.
  */
 public function clearAllReferences($deep = false)
 {
     if ($deep && !$this->alreadyInClearAllReferencesDeep) {
         $this->alreadyInClearAllReferencesDeep = true;
         if ($this->collDetailBarangMasuks) {
             foreach ($this->collDetailBarangMasuks as $o) {
                 $o->clearAllReferences($deep);
             }
         }
         if ($this->aSupplier instanceof Persistent) {
             $this->aSupplier->clearAllReferences($deep);
         }
         $this->alreadyInClearAllReferencesDeep = false;
     }
     // if ($deep)
     if ($this->collDetailBarangMasuks instanceof PropelCollection) {
         $this->collDetailBarangMasuks->clearIterator();
     }
     $this->collDetailBarangMasuks = null;
     $this->aSupplier = null;
 }