/** * Delete a customer record */ public function deleteAction() { $productsTable = new Products(); $product = $productsTable->find($this->_getParam('id'))->current(); !is_null($product) && $product->delete(); $this->_redirect('/products'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { //$confirmation_code = str_random(30); $data = Input::except(array('_token')); $rule = array('custId' => 'required', 'custName' => 'required', 'custEmail' => 'required', 'prodId' => 'required', 'pname' => 'required', 'price' => 'required', 'stockUnit' => 'required', 'sales' => 'required', 'quantity' => 'required'); $validator = Validator::make($data, $rule); if ($validator->fails()) { return Redirect::back()->withInput()->withErrors($validator); } else { $newproduct = new Products(); $newproduct->prodId = Input::get('prodId'); $newproduct->pname = Input::get('pname'); $newproduct->descr = Input::get('descr'); $newproduct->location = Input::get('location'); $newproduct->purl = Input::get('purl'); $newproduct->price = Input::get('price'); $newproduct->pvat = Input::get('pvat'); $newproduct->sales = Input::get('sales'); $newproduct->svat = Input::get('svat'); $newproduct->quantity = Input::get('quantity'); $newproduct->swarn = Input::get('swarn'); $newproduct->save(); return Redirect::to('/back_end/manageProduct')->with('success', true)->with('message', 'Product Added Successfully'); } }
public function getResult() { // Date in the past header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // always modified header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // HTTP/1.1 header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); // HTTP/1.0 header("Pragma: no-cache"); if (isset($_POST['process'])) { } else { $products = new Products(); $this->licenseData['prices2'] = $this->licenseData['prices']; $this->licenseData['prices'] = json_encode($this->licenseData['prices']); $this->licenseData['licenses'] = json_encode($this->licenseData['lic']); $this->licenseData['bundle_prices'] = json_encode(isset($this->licenseData['bundle_prices']) ? $this->licenseData['bundle_prices'] : NULL); $this->licenseData['bundle_product_prices'] = json_encode(isset($this->licenseData['bundle_product_prices']) ? $this->licenseData['bundle_product_prices'] : NULL); $this->licenseData['offer_prices'] = json_encode($this->licenseData['offer_prices']); // $this->licenseData['geo_currency'] = json_encode($this->licenseData['geo_currency']); $this->licenseData['products'] = $products->getProductsShort(TRUE, FALSE, 3); $this->licenseData['product_versions'] = $products->getProductMajorVersions($this->productId); $this->licenseData['product'] = $products->getProductById($this->productId); $this->licenseData['currencies'] = json_encode($this->licenseData['currencies']); return $this->licenseData; } }
function product_log($id, $status, $bean, $status_action, $old_status) { $productLog = new ProductLog(); $product = new Products(); $product->retrieve($id); if ($old_status != $status || empty($product->date_modified)) { $productLog->product_name = $product->name; $productLog->product_id = $product->id; $productLog->from_status = $old_status; $product->status = $status; $product->save($GLOBALS['check_notify']); $productLog->to_status = $product->status; var_dump($productLog->object_name); var_dump($productLog->object_id); $productLog->bean_name = $bean->object_name; $productLog->bean_id = $bean->id; var_dump($productLog->object_name); var_dump($productLog->object_id); var_dump($bean->object_name); var_dump($bean->object_id); $productLog->action = $status_action; if (!empty($_REQUEST['status_action'])) { $productLog->action = $_REQUEST['status_action']; } $productLog->save($GLOBALS['check_notify']); } }
public function testMany() { $this->_mock = new Mock_Database($this, array(array('many', "SELECT products.*\nFROM products", array(), null, array('return' => array(array('id' => 1), array('id' => 2)))), array('many', "SELECT products_options.*\nFROM products_options\nWHERE `product_id` IN (?, ?)", array(1, 2), null, array('return' => array(array('id' => 3, 'product_id' => 1), array('id' => 4, 'product_id' => 2)))))); \Snowfire\Database\Model::database($this->_mock); $prod_model = new Products(); $opt_model = new Products_Options(); $this->assertEquals(array(array('id' => 1, 'options' => array(array('id' => 3, 'product_id' => 1))), array('id' => 2, 'options' => array(array('id' => 4, 'product_id' => 2)))), $prod_model->many(array('foreign_models' => array('options' => $opt_model)))); }
/** *Export all orders, *customers, product into a xml file * */ public static function exportAll() { // create the xml customer file $customers = new Customers(); $theCustomers = $customers->bulk_xml(); // create the xml product $products = new Products(); $theCustomers = $products->bulk_xml(); }
public function testObject() { $product = new Product(); $product->setTitle('title'); $product->setSize('10k'); $product->setUnitPrice('10'); $product->setDescription('description'); $products = new Products(); $products->add($product); $this->assertArrayHasKey('total', $products->getItems()); }
/** * @see ApplicationView::createUserInterface() */ protected function createUserInterface() { parent::createUserInterface(); $this->addStyle('/css/home.css'); $resourceBundle = Application::getInstance()->getBundle(); $products = $this->products->getProducts(); if (count($products) == 0) { $this->contentPanel->addChild(new Heading(2))->addChild(new Text($resourceBundle->getString('NO_PRODUCT'))); } else { $this->contentPanel->addChild(new ProductList())->setProductList($products); } }
public function get($productid) { $this->authenticate(); if (empty($productid)) { throw new Shineisp_Api_Exceptions(400002, ":: 'productid' field"); exit; } $product = new Products(); $details = $product->getAllInfo($productid); $details['ProductsUpgrades'] = ProductsUpgrades::getItemsbyProductID($productid); return $details; }
public function GetWaitingList($id_user) { $sql = "SELECT wl.id_product, p.art, p.name, p.translit , p.img_1,\r\n\t\t\tp.price_opt, p.price_mopt, p.old_price_opt, p.visible\r\n\t\t\tFROM " . _DB_PREFIX_ . "waiting_list AS wl\r\n\t\t\tLEFT JOIN " . _DB_PREFIX_ . "product AS p\r\n\t\t\t\tON wl.id_product = p.id_product\r\n\t\t\tWHERE wl.id_user = '******'\r\n\t\t\tORDER BY wl.id_product"; if (!($arr = $this->db->GetArray($sql))) { return false; } foreach ($arr as &$value) { $Products = new Products(); $value['images'] = $Products->GetPhotoById($value['id_product']); } return $arr; }
/** * @param int $customerId * @param int $productId */ public function findProductCoalesced($customerId, $productId) { $productsTable = new Products(); $p = $productsTable->find($productId)->current(); $cp = $this->find($productId, $customerId)->current(); if ($cp) { $productCoalesced = array('product_id' => $cp->product_id, 'sku' => $cp->sku ?: $p->sku, 'name' => $cp->name ?: $p->name, 'description' => $cp->description ?: $p->description, 'unit_price' => $cp->unit_price ?: $p->unit_price); } else { $productCoalesced = array('product_id' => $p->product_id, 'sku' => $p->sku, 'name' => $p->name, 'description' => $p->description, 'unit_price' => $p->unit_price); } return $productCoalesced; }
public function init() { // Set the custom decorator $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $translate = Shineisp_Registry::get('Zend_Translate'); $this->addElement('text', 'quantity', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Quantity'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'setupfee', array('filters' => array('StringTrim'), 'label' => $translate->_('Setup fees'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'discount', array('filters' => array('StringTrim'), 'label' => $translate->_('Discount'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'cost', array('filters' => array('StringTrim'), 'label' => $translate->_('Cost'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('select', 'product_id', array('filters' => array('StringTrim'), 'required' => false, 'label' => $translate->_('Products'), 'class' => 'form-control')); $this->getElement('product_id')->setAllowEmpty(false)->setMultiOptions(Products::getList(true)); $this->addElement('text', 'price', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Price'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('select', 'billing_cycle_id', array('label' => $translate->_('Billing Cycle'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('billing_cycle_id')->setAllowEmpty(false)->setMultiOptions(BillingCycle::getList(true)); $this->addElement('text', 'date_start', array('filters' => array('StringTrim'), 'label' => $translate->_('Start Date'), 'required' => true, 'decorators' => array('Bootstrap'), 'class' => 'form-control date', 'dateformat' => Settings::getJsDateFormat())); $this->addElement('text', 'date_end', array('filters' => array('StringTrim'), 'label' => $translate->_('Expiry Date'), 'decorators' => array('Bootstrap'), 'class' => 'form-control date', 'dateformat' => Settings::getJsDateFormat())); $this->addElement('textarea', 'description', array('filters' => array('StringTrim'), 'label' => $translate->_('Description'), 'decorators' => array('Bootstrap'), 'rows' => 5, 'class' => 'form-control')); $this->addElement('textarea', 'parameters', array('filters' => array('StringTrim'), 'label' => $translate->_('Service Panel Configuration'), 'decorators' => array('Bootstrap'), 'rows' => 5, 'description' => $translate->_('Parameters model accepted: {"domain":{"name":"domain.com","tld":"2","action":"renewDomain","authcode":null}}'), 'class' => 'form-control')); $this->addElement('select', 'status_id', array('label' => $translate->_('Status'), 'required' => true, 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('status_id')->setAllowEmpty(false)->setMultiOptions(Statuses::getList('orders')); $this->addElement('select', 'autorenew', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Auto Renewal'), 'class' => 'form-control', 'multioptions' => array(0 => 'NO', 1 => 'YES'))); $this->addElement('multiselect', 'domains', array('label' => $translate->_('Available Domains'), 'decorators' => array('Bootstrap'), 'class' => 'form-control tmpitems')); $this->getElement('domains')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Domains::getList()); $this->addElement('multiselect', 'domains_selected', array('label' => $translate->_('Selected domains'), 'decorators' => array('Bootstrap'), 'class' => 'form-control items')); $this->getElement('domains_selected')->setRegisterInArrayValidator(false); // Disable the Validator in order to manage a dynamic list. $this->addElement('hidden', 'detail_id'); }
/** * compareAction * Compare the services between themselves */ public function productsAction() { $code = $this->getRequest()->getParam('code'); if ($code) { // Get all the data from the database $data = Products::GetProductsByGroupCode($code); } if (!empty($data['products'][0]['ProductsAttributesGroups']['name'])) { $this->view->headTitle()->prepend($this->translator->_("Compare %s", $data['products'][0]['ProductsAttributesGroups']['name'])); $this->view->title = $data['products'][0]['ProductsAttributesGroups']['name']; } else { $this->view->title = $code; } // Check the existence of the mandatories attributes if (!empty($data['attributes'][0])) { $this->view->attributes = $data['attributes']; } // Check if there are values set for the group of the product selected if (!empty($data['attributes_values'][0])) { $this->view->values = $data['attributes_values']; } // Get the products if (!empty($data['products'][0])) { $this->view->products = $data['products']; } // Render the page $this->_helper->viewRenderer('index'); }
public function searchAction() { $numberPage = 1; if ($this->request->isPost()) { $query = Criteria::fromInput($this->di, "Products", $_POST); $this->persistent->searchParams = $query->getParams(); } else { $numberPage = $this->request->getQuery("page", "int"); if ($numberPage <= 0) { $numberPage = 1; } } $parameters = array(); if ($this->persistent->searchParams) { $parameters = $this->persistent->searchParams; } $products = Products::find($parameters); if (count($products) == 0) { $this->flash->notice("没找到任何类型"); return $this->forward("products/index"); } $paginator = new Phalcon\Paginator\Adapter\Model(array("data" => $products, "limit" => 5, "page" => $numberPage)); $page = $paginator->getPaginate(); $this->view->setVar("page", $page); }
public function Show($parameters) { $output = ""; $ns = new Zend_Session_Namespace(); $languageID = Languages::get_language_id($ns->lang); $mainviewhelper = new Zend_View(); $mainviewhelper->addBasePath(APPLICATION_PATH . '/modules/default/views/'); $view = new Zend_View(); $view->addScriptPath('../library/Shineisp/Custom/views'); $translator = Shineisp_Registry::getInstance()->Zend_Translate; if (!empty($parameters['code'])) { $code = $parameters['code']; } else { return ""; } // Get the products $data = Products::GetProductsByGroupCode($code, $languageID); // Check the existence of the mandatories attributes if (!empty($data['attributes'][0])) { $view->attributes = $data['attributes']; } // Check if there are values set for the group of the product selected if (!empty($data['attributes_values'][0])) { $view->values = $data['attributes_values']; } // Get the products if (!empty($data['products'][0])) { $view->products = $data['products']; } $view->mainviewhelper = $mainviewhelper; // Path of the template return $view->render('productsattributes.phtml'); }
public function init() { // Set the custom decorator $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $translate = Shineisp_Registry::get('Zend_Translate'); $this->addElement('text', 'date_start', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Creation date'), 'decorators' => array('Bootstrap'), 'class' => 'form-control date', 'dateformat' => Settings::getJsDateFormat())); $this->addElement('text', 'date_end', array('filters' => array('StringTrim'), 'label' => $translate->_('Expiry Date'), 'decorators' => array('Bootstrap'), 'class' => 'form-control date', 'dateformat' => Settings::getJsDateFormat())); $this->addElement('text', 'quantity', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Quantity'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('textarea', 'message', array('filters' => array('StringTrim'), 'label' => $translate->_('Message'), 'decorators' => array('Bootstrap'), 'class' => 'col-lg-12 form-control wysiwyg')); $this->addElement('textarea', 'note', array('filters' => array('StringTrim'), 'label' => $translate->_('Note'), 'description' => $translate->_('Write here a note. An email will be sent to the ISP staff.'), 'decorators' => array('Bootstrap'), 'class' => 'col-lg-12 form-control wysiwyg')); $this->addElement('textarea', 'setup', array('filters' => array('StringTrim'), 'label' => $translate->_('Setup Configuration'), 'description' => $translate->_('Here you can read the service configuration written by the ISP modules. These information are read-only.'), 'decorators' => array('Bootstrap'), 'class' => 'col-lg-12')); $this->addElement('select', 'order_id', array('label' => $translate->_('Orders'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('order_id')->setAllowEmpty(false)->setMultiOptions(Orders::getList(true)); $this->addElement('multiselect', 'domains', array('label' => $translate->_('Available domains'), 'decorators' => array('Bootstrap'), 'class' => 'form-control col-lg-12 tmpitems')); $this->getElement('domains')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Domains::getList()); $this->addElement('multiselect', 'domains_selected', array('label' => $translate->_('Selected domains'), 'decorators' => array('Bootstrap'), 'class' => 'form-control col-lg-12 items')); $this->getElement('domains_selected')->setRegisterInArrayValidator(false); // Disable the Validator in order to manage a dynamic list. $this->addElement('select', 'product_id', array('label' => $translate->_('Products'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('product_id')->setAllowEmpty(false)->setMultiOptions(Products::getList(true)); $this->addElement('select', 'billing_cycle_id', array('label' => $translate->_('Billing Cycle'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('billing_cycle_id')->setAllowEmpty(false)->setMultiOptions(BillingCycle::getList(true)); $this->addElement('select', 'status_id', array('label' => $translate->_('Status'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('status_id')->setAllowEmpty(false)->setMultiOptions(Statuses::getList('orders', false, true)); $this->addElement('select', 'autorenew', array('filters' => array('StringTrim'), 'decorators' => array('Bootstrap'), 'label' => $translate->_('Auto Renewal'), 'description' => $translate->_('Enable or disable the automatic renewal of the service'), 'class' => 'form-control')); $this->getElement('autorenew')->setAllowEmpty(false)->setMultiOptions(array('1' => $translate->_('Yes, I would like to renew the service at the expiration date.'), '0' => $translate->_('No, I am not interested in the service renew.'))); $this->addElement('hidden', 'detail_id'); }
public function actionUpdate($id) { self::validateAdmin(); $platformList = Platform::getPlatformListByAdmin(); $genreList = Genre::getGenresListByAdmin(); $product = Products::getProductById($id); if (isset($_POST['submit'])) { $option['code'] = $_POST['code']; $option['name'] = $_POST['name']; $option['price'] = $_POST['price']; $option['platform_id'] = $_POST['platform_id']; $option['genre_id'] = $_POST['genre_id']; $option['brand'] = $_POST['brand']; $option['description'] = $_POST['description']; $option['availability'] = $_POST['availability']; $option['is_recomend'] = $_POST['is_recomend']; $option['is_new'] = $_POST['is_new']; $option['status'] = $_POST['status']; $errors = false; if (!isset($option['name']) || empty($option['name'])) { $errors[] = "Введите имя товара"; } if ($errors == false) { Products::updateProduct($id, $option); if ($id) { if (is_uploaded_file($_FILES['image']['tmp_name'])) { move_uploaded_file($_FILES['image']['tmp_name'], $_SERVER["DOCUMENT_ROOT"] . "/upload/images/products/(" . $id . ").png"); } } } header("Location: /evkazolinAdminka/product/"); } require_once ROOT . '/views/admin_product/update.php'; return true; }
function listRss() { header("Content-Type: application/xml; charset=UTF-8"); $location = Url::rss(); if ($match = Uri::match('^(.*?)$')) { $location = ROOT_URL . $match[1]; $reLocation = base64_encode($location); if ($loadData = Cache::loadKey($reLocation, 60)) { $loadData = json_decode($loadData, true); return $loadData; } } $inputData = array('limitShow' => 15, 'limitPage' => 0); if ($match = Uri::match('\\/page\\/(\\d+)')) { $inputData['limitPage'] = $match[1]; } if ($match = Uri::match('\\/category\\/(\\d+)')) { $id = $match[1]; $inputData['where'] = "where catid='{$id}'"; } if ($match = Uri::match('rss\\/products')) { $loadData = Products::get($inputData); } else { $loadData = Post::get($inputData); } $reLocation = base64_encode($location); Cache::saveKey($reLocation, json_encode($loadData)); return $loadData; }
public function actionView($productId) { $categories = array(); $categories = Platform::getPlatformList(); $product = Products::getProductById($productId); $productId = $product['id']; $platform = Platform::getPlatformById($product['platform_id']); $comments = Comment::getCommentsByProductId($productId); //COMMENTS if (isset($_POST['submit'])) { $userComment = $_POST['message']; $errors = false; if (!Comment::validateMessage($userComment)) { $errors[] = "Введите собщение"; } if (User::isGuest()) { $userName = $_POST['name']; $userEmail = $_POST['email']; if (!User::validateUsername($userName)) { $errors[] = "Неверное имя"; } if (!User::validateEmail($userEmail)) { $errors[] = "Неверный Email"; } $userId = false; } else { $userId = User::validateLogged(); $user = User::getUserById($userId); $userName = $user['name']; } Comment::addComment($userComment, $userId, $userName, $productId); } require_once ROOT . '/views/product/view.php'; return true; }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $discountTypes = ['' => 'Select Discount Type', 'percentage' => 'Percentage', 'fixed' => 'Fixed']; $statuses = Discounts::$statuses; $discount = Discounts::find($id); $product = Products::find($discount->product_id); return View::make('discounts.edit', compact('discountTypes', 'product', 'statuses', 'discount')); }
/** Constructor which will set the importable_fields as $this->importable_fields[$key]=1 in this object where key is the fieldname in the field table */ function ImportProduct() { parent::Products(); $this->log = LoggerManager::getLogger('import_product'); $this->db = PearDatabase::getInstance(); $this->db->println("IMP ImportProduct"); $this->initImportableFields("Products"); $this->db->println($this->importable_fields); }
public function exists($id) { $exists = Products::where('supplierId', $id)->first(); if ($exists == null) { return false; } else { return true; } }
public function productAction($id) { if ($id) { $product = Products::findFirst("id =" . $id); $this->view->product = $product; } else { $this->response->redirect("/service/index"); } }
public function run() { $faker = Faker\Factory::create(); //Products::truncate(); $suppliers = Suppliers::all()->lists('id'); $categories = Categories::all()->lists('id'); for ($i = 0; $i < 20; $i++) { $products = Products::create(array('name' => $faker->word, 'quantity' => $faker->numberBetween(1, 900), 'unitPrice' => $faker->randomFloat(5, 1, 5000), 'details' => $faker->text, 'color' => $faker->colorName, 'supplierProductId' => $faker->randomNumber, 'supplierId' => $faker->randomElement($suppliers), 'categoryId' => $faker->randomElement($categories))); } }
public function ProductImage($productid, $maxWidth = 100, $maxHeight = 100, $showall = false) { $NS = new Zend_Session_Namespace('Default'); $this->view->width = $maxWidth; $this->view->height = $maxHeight; $this->view->showall = $showall; $this->view->resources = ProductsMedia::getMediabyProductId($productid, "*", $NS->langid); $this->view->productdata = Products::getAllInfo($productid, $NS->langid); return $this->view->render('partials/media.phtml'); }
/** * ServicesExpiration * List of all the services near the expiring date * @return array */ public function ServicesExpiration() { $ns = new Zend_Session_Namespace(); if (!empty($ns->customer)) { $data = $ns->customer; return array('records' => Products::getExpiringProducts($data['customer_id'], $ns->langid), 'actions' => array('/services/edit/id/' => 'Show')); } else { return null; } }
/** * Handle post data and show our create form */ public function postCreate() { $error = false; Gallery::create(['image' => Input::file('images')]); if ($product = Products::create(Input::except('images', '_token'))) { return Redirect::to(admin_path('products/edit/' . $product->id)); } View::share('error', 'Couldn’t create your product.'); return self::getCreate(); }
public function actionIndex() { $platforms = array(); $platforms = Platform::getPlatformList(); $genres = array(); $genres = Genre::getGenreList(); $productList = array(); $productList = Products::getProducts(6); require_once ROOT . '/views/site/index.php'; return true; }
public function indexAction() { $ns = new Zend_Session_Namespace(); $search = $this->getRequest()->getParam('q'); if (!empty($search)) { $this->view->search = htmlspecialchars($search); $this->view->results = Products::search($search, $ns->langid, false); } else { $this->_redirect('/'); } }
public function editAction($id) { if (!$this->request->isPost()) { $product = Products::findFirstById($id); if (!$product) { $this->flash->error("该商品不存在"); return $this->forward("product/index"); } $this->view->form = new ProductsForm($product, array('edit' => true)); } }