function getData() { if ($_SERVER['REQUEST_METHOD'] == 'POST') { //load visitedProduct //load userinfo bar $output['visitedProduct'] = $this->getVisitedProduct(); $output['userInfo'] = $this->getUserInfo(); //load product comment and add product to visited list $productId = $this->input->post('productId'); if ($productId != 0) { $output['productComment'] = $this->getProductComment($productId); $this->addProductCookie($productId); } //load compare product $compareCookie = $this->input->cookie('compareProduct'); $compareArray = explode(",", $compareCookie); array_push($compareArray, 0); $compareProduct = new product(); $compareProduct->where_in('id', $compareArray); $compareProduct->get_iterated(); $this->compareProduct = $compareProduct; $this->compareArray = $compareArray; $dis['base_url'] = base_url(); $output['compareProduct'] = $this->load->view('front/includes/compareProductSmall', $dis, true); $output['compareArray'] = $compareArray; //get number of cart item $output['numCart'] = $this->countCartItem(); $this->output->set_header('Content-type: application/json'); $this->output->set_output(json_encode($output)); } else { show_404(); } }
public function check_reorder_level() { global $db; global $auth_session; $domain_id = domain_id::get($this->domain_id); //sellect qty and reorder level $inventory = new product(); $sth = $inventory->select_all('count'); $inventory_all = $sth->fetchAll(PDO::FETCH_ASSOC); $email = ""; foreach ($inventory_all as $row) { if ($row['quantity'] <= $row['reorder_level']) { $message = "The quantity of Product: " . $row['description'] . " is " . siLocal::number($row['quantity']) . ", which is equal to or below its reorder level of " . $row['reorder_level']; $return['row_' . $row['id']]['message'] = $message; $email_message .= $message . "<br />\n"; } } //print_r($return); #$attachment = file_get_contents('./tmp/cache/' . $pdf_file_name); $email = new email(); $email->notes = $email_message; $email->from = $email->get_admin_email(); $email->to = $email->get_admin_email(); #$email -> bcc = "justin@localhost"; $email->subject = "Simple Invoices reorder level email"; $email->send(); return $return; }
public function insert_product_warehouse($form) { $data = array(); $data['product_id'] = $form['product_id']; $data['warehouse_cost'] = $form['product_cost']; $data['warehouse_price'] = $form['product_price']; $data['warehouse_quantity'] = $form['product_quantity']; $data['warehouse_barcode'] = $form['product_barcode']; $data['warehouse_qtytype'] = $form['p_qtytype']; $data['warehouse_sp_bill'] = $form['sup_bill']; $this->insert($this->table_name, $data); $accounts = new accounts(); $products = new product(); // Create GL $amount = $form['product_cost'] * $products->generate_item_quantity($form['product_id'], $form['p_qtytype'], $form['product_quantity']); $type = 'debit'; $account = 'Purchase'; $account_type = 'Stock'; $date = $accounts->_date('Y-m-d H:i:s', date('d-m-Y')); $results = $accounts->create_general_ledger($amount, $type, $account, $account_type, $date); // Purchase $product = $form['product_id']; $cost = $form['product_cost']; $quantity = $products->generate_item_quantity($form['product_id'], $form['p_qtytype'], $form['product_quantity']); $date = $date; $account = 'purchase'; $account_type = 'stock'; $results = $accounts->create_purchase($product, $cost, $quantity, $date, $account, $account_type); return $this->row_count(); }
/** * Transforms an object (product) to a string (number). * * @param product|null $product * @return string */ public function transform($product) { if (null === $product) { return ''; } return $product->getId(); }
function deleteProduct_Action() { $product_id = $_GET['product_id']; $list_url = 'http://' . HOST . '/' . APPLICATION . '/index.php?page=home'; $product = new product(); $result = $product->deleteProduct($product_id); header("Location: {$list_url}"); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { //dd($request); $product = new product(); $product->name = $request->name; $product->price = $request->price; $product->save(); return redirect()->route('product.index'); }
/** * Rewriting this method to output new urls. * Checks if a rewrite already exists, otherwise creates it. * * @param product $product * @param category $category * @param array $params */ public function getReviewsUrl($product, $category = null, $params = array()) { $routePath = ''; $routeParams = $params; $storeId = $product->getStoreId(); if (!$storeId) { $storeId = Mage::app()->getStore()->getId(); $product->setStoreId($storeId); } $categoryId = $product->getCategoryId() && !$product->getDoNotUseCategoryId() ? $product->getCategoryId() : null; $idPath = sprintf('reviews/%d', $product->getId()); //if ($categoryId) { // $idPath = sprintf('%s/%d', $idPath, $categoryId); //} $rewrite = $this->getUrlRewrite(); $rewrite->setStoreId($storeId)->loadByIdPath($idPath); $oldRequestPath = $product->getRequestPath(); if ($rewrite->getId()) { // REWRITE RULE EXISTS $requestPath = $rewrite->getRequestPath(); $product->setRequestPath($requestPath); } else { // CREATE REWRITE RULE $model = Mage::getModel('reviewsearchfriendlyurls/url'); $requestPath = $model->addUrlRewrite($product); } if (isset($routeParams['_store'])) { $storeId = Mage::app()->getStore($routeParams['_store'])->getId(); } if ($storeId != Mage::app()->getStore()->getId()) { $routeParams['_store_to_url'] = true; } if (!empty($requestPath)) { $routeParams['_direct'] = $requestPath; } else { $routePath = 'catalog/product/view'; $routeParams['id'] = $product->getId(); $routeParams['s'] = $product->getUrlKey(); //if ($categoryId) { // $routeParams['category'] = $categoryId; //} } // reset cached URL instance GET query params if (!isset($routeParams['_query'])) { $routeParams['_query'] = array(); } $url = $this->getUrlInstance()->setStore($storeId)->getUrl($routePath, $routeParams); $product->setRequestPath($oldRequestPath); return $url; }
function bill_checkout($amount, $invoice, $currency_iso, $acct_fields, $total_recurring = false, $recurr_bill_arr = false) { # Validate the currency: if (!$this->validate_currency($currency_iso)) { return false; } # Special JPY formatting: if ($currency_iso == 'JPY') { $amount = round($amount); } # Get the regular period for this subscription: $sched = $recurr_bill_arr[0]["recurr_schedule"]; if ($sched == 0) { $p3 = '1'; $t3 = 'W'; } elseif ($sched == 1) { $p3 = '1'; $t3 = 'M'; } elseif ($sched == 2) { $p3 = '3'; $t3 = 'M'; } elseif ($sched == 3) { $p3 = '6'; $t3 = 'M'; } elseif ($sched == 4) { $p3 = '1'; $t3 = 'Y'; } elseif ($sched == 5) { $p3 = '2'; $t3 = 'Y'; } $url = "https://www.paypal.com/cgi-bin/webscr"; # Get the next bill date for this subscription: if ($recurr_bill_arr[0]["recurr_type"] == "1") { # Pro-rate billing: include_once PATH_MODULES . 'product/product.inc.php'; $product = new product(); $arr = $product->recurrDates($recurr_bill_arr[0]["recurr_schedule"], $recurr_bill_arr[0]["recurr_weekday"], $recurr_bill_arr[0]["recurr_week"]); $remain_time = $arr['end'] - time(); $period1 = round($remain_time / 86400); $subscr_date = date("Y-m-d", $arr["end"]); $vals = array(array('cmd', '_xclick-subscriptions'), array('bn', 'Agileco.AgileBill'), array('business', $this->cfg['email']), array('item_name', "Invoice No:" . $invoice), array('return', $this->success_url . $invoice), array('cancel_return', $this->decline_url . $invoice), array('notify_url', $this->return_url), array('currency_code', $currency_iso), array('invoice', $invoice), array('first_name', $acct_fields['first_name']), array('last_name', $acct_fields['last_name']), array('payer_business_name', $acct_fields['company']), array('address_street', $acct_fields['address1']), array('address_city', $acct_fields['city']), array('address_state', $acct_fields['state']), array('address_zip', $acct_fields['zip']), array('address_country', $acct_fields['country_id']), array('payer_email', $acct_fields['email']), array('payer_id', $acct_fields['id']), array('txn_type', 'subscr_signup'), array('a1', $amount), array('p1', $period1), array('t1', 'D'), array('a3', $total_recurring), array('p3', $p3), array('t3', $t3), array('src', "1"), array('sra', "1")); } else { # Bill on anniversary: $vals = array(array('cmd', '_xclick-subscriptions'), array('business', $this->cfg['email']), array('item_name', "Invoice No:" . $invoice), array('return', $this->success_url . $invoice), array('cancel_return', $this->decline_url . $invoice), array('notify_url', $this->return_url), array('currency_code', $currency_iso), array('invoice', $invoice), array('first_name', $acct_fields['first_name']), array('last_name', $acct_fields['last_name']), array('payer_business_name', $acct_fields['company']), array('address_street', $acct_fields['address1']), array('address_city', $acct_fields['city']), array('address_state', $acct_fields['state']), array('address_zip', $acct_fields['zip']), array('address_country', $acct_fields['country_id']), array('payer_email', $acct_fields['email']), array('payer_id', $acct_fields['id']), array('txn_type', 'subscr_signup'), array('a1', $amount), array('p1', $p3), array('t1', $t3), array('a3', $total_recurring), array('p3', $p3), array('t3', $t3), array('src', "1"), array('sra', "1")); } $this->post_vars($url, $vals); return true; }
public function __construct($pID = -1) { if (is_null(self::$conn)) { self::$conn = mysqli_connect('localhost', 'root', 'iti', 'eShop'); } if ($pID != -1) { $query = "select * from products where pID={$pID} "; $result = mysqli_query(self::$conn, $query); // if(mysqli_num_rows($result)>0) // { $product = mysqli_fetch_assoc($result); $this->pID = $product['pID']; $this->pName = $product['pName']; $this->pPrice = $product['pPrice']; $this->pQuantity = $product['pQuantity']; $this->pImg = $product['pImg']; $this->pDesc = $product['pDesc']; $this->scID = $product['scID']; // } // else // } // return 'undefined'; // } } }
public function get_products() { $result = array(); $query = 'SELECT Id, Unitprice, Pricebook2.Id, Pricebook2.Name, ' . product::get_sf_fields() . ', LastModifiedDate FROM PricebookEntry WHERE Product2.Data_Source__c = \'New Records Salesforce\' AND LastModifiedDate > ' . utcDateFormat(time() + 7200); $response = $this->conn->query($query); foreach ($response->records as $record) { if (!isset($result[$record->Product2->Id])) { $result[$record->Product2->Id] = $record->Product2; } $key = 'Standard'; switch ($record->Pricebook2->Name) { case 'Price Book 1': $key = 'PRICE1'; break; case 'Price Book 2': $key = 'PRICE2'; break; case 'Price Book 3': $key = 'PRICE3'; break; } $result[$record->Product2->Id]->{$key} = $record->UnitPrice; $result[$record->Product2->Id]->LastModifiedDate = $record->LastModifiedDate; } return $result; }
public function __construct($params = array(), $get_assoc = false, $get_attached = true) { global $db; parent::__construct($params, $get_assoc, $get_attached); //if (!empty($this->id)) $this->extra_fields = expUnserialize($this->extra_fields); $this->price = $this->getBasePrice(); }
static function install() { $db = Database::instance(); $db->query("CREATE TABLE IF NOT EXISTS {products} (\n `id` int(9) NOT NULL auto_increment,\n `name` TEXT NOT NULL,\n `cost` INTEGER(9) default 0,\n `description` varchar(1024),\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); product::create("4x6", 5, "4\"x6\" print"); product::create("8x10", 25, "8\"x10\" print"); product::create("8x12", 30, "8\"x12\" print"); module::set_version("basket", 1); }
static function photo_top($theme) { if (product::isForSale($theme->item()->id)) { $view = new View("add_to_basket.html"); $view->item = $theme->item(); return $view->render(); } return ""; }
function productsList() { $page = new page(); $prod = new product(); if (isset($_GET['sort'])) { if ($_GET['sort'] == "ASC") { $sort = "DESC"; } else { $sort = "ASC"; } } else { $sort = ""; } $params = array(); $params = $page->setProductsParams(); $products = $prod->getList($params, $sort); $page->displayProducts($products, $params, $sort); }
public function __construct() { $servername = "localhost"; $username = "******"; $password = "******"; $dbname = "ecommerce"; if (is_null(self::$conn)) { self::$conn = mysqli_connect('localhost', 'root', 'iti', 'ecommerce'); } }
function show_productSale_new($template) { global $TPL; global $productSaleItemsDoExist; global $productSaleID; $taxName = config::get_config_item("taxName"); $productSaleItem = new productSaleItem(); $productSaleItem->set_values(); // wipe clean $product = new product(); $ops = $product->get_assoc_array("productID", "productName"); $TPL["productList_dropdown"] = page::select_options($ops, $productSaleItem->get_value("productID")); $productSaleItemsDoExist and $TPL["display"] = "display:none"; if ($taxName) { $TPL["sellPriceTax_check"] = sprintf(" <input type='checkbox' name='sellPriceIncTax[]' value='1'%s> inc %s", $productSaleItem->get_value("sellPriceIncTax") ? ' checked' : '', $taxName); } $TPL["psid"] = $productSaleID; // poorly named template variable to prevent clobbering include_template($template); }
public function detail() { //get expenseaccount $expenseaccountobj = new expenseaccount(); $detail['expense_account_all'] = $expenseaccountobj->get_all(); //get customers with domain_id from session by constructor $customerobj = new customer(); $detail['customer'] = $customerobj->get(); $detail['customer_all'] = $customerobj->get_all(); //get billers with domain_id from session by constructor $billerobj = new biller(); $detail['biller_all'] = $billerobj->get_all(); //get invoices $invoiceobj = new invoice(); $detail['invoice_all'] = $invoiceobj->get_all(); //get products $productobj = new product(); $detail['product_all'] = $productobj->get_all(); return $detail; }
/** * 显示商品列表 */ public function index() { $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); try { //* 初始化返回数据 */ $return_data = array('assoc' => NULL, 'count' => 0); //* 收集请求数据 ==根据业务逻辑定制== */ $request_data = $this->input->get(); $request_data['status'] = isset($request_data['status']) ? (int) $request_data['status'] : 0; $struct = product::get_struct($request_data); $query_struct_current = $struct['query']; $query_struct_current['where']['type'] = array(ProductService::PRODUCT_TYPE_GOODS, ProductService::PRODUCT_TYPE_CONFIGURABLE, ProductService::PRODUCT_TYPE_ASSEMBLY); $request_struct_current = $struct['request']; // 每页条目数 controller_tool::request_per_page($query_struct_current, $request_data); $return_data = BLL_Product::index($query_struct_current); // 模板输出 分页 $this->pagination = new Pagination(array('total_items' => $return_data['count'], 'items_per_page' => $query_struct_current['limit']['per_page'])); $query_struct_current['limit']['page'] = $this->pagination->current_page; //* 如果是ajax请求缩减返回的字段 ==根据业务逻辑定制== */ if ($this->is_ajax_request()) { $requestkeys = array('id', 'category_id', 'title', 'store', 'on_sale', 'price', 'sku'); array_walk($return_data['assoc'], 'util::simplify_return_array', $requestkeys); } //* 补充&修改返回结构体 */ $return_struct['status'] = 1; $return_struct['code'] = 200; $return_struct['msg'] = ''; $return_struct['content'] = $return_data; //* 请求类型 */ if ($this->is_ajax_request()) { // ajax 请求 // json 输出 $this->template->content = $return_struct; } else { //* html 输出 ==根据业务逻辑定制== */ //* 模板输出 */ $this->template->return_struct = $return_struct; $content = new View($this->package_name . '/' . $this->class_name . '/' . __FUNCTION__); //* 变量绑定 */ $this->template->title = Kohana::config('site.name'); $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->request_data = $request_data; $this->template->content->request_struct = $request_struct_current; $this->template->content->query_struct = $query_struct_current; //* 返回结构体绑定 */ $this->template->content->return_struct = $return_struct; } // end of request type determine } catch (MyRuntimeException $ex) { $this->_ex($ex, $return_struct, $request_data); } }
public function index() { $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); try { //* 初始化返回数据 */ $return_data = array('assoc' => NULL, 'count' => 0); //* 收集请求数据 ==根据业务逻辑定制== */ $request_data = $this->input->get(); $site_ids = role::get_site_ids(); if (empty($site_ids)) { throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 403); } $in_site_id = site::id(); if (isset($request_data['site_id']) and $request_data['site_id'] === '0') { unset($request_data['site_id']); } if (isset($request_data['site_id']) and !in_array($request_data['site_id'], $site_ids)) { throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 403); } if ($in_site_id > 0) { $query_site_id = $in_site_id; } else { throw new MyRuntimeException(Kohana::lang('o_global.select_site'), 400); } $struct = product::get_struct($request_data, $query_site_id); $query_struct_current = $struct['query']; $request_struct_current = $struct['request']; $query_struct_current['limit']['per_page'] = 1; $return_data = BLL_Product::index($query_struct_current); $products = $return_data['assoc']; $content = new View($this->package_name . '/' . $this->class_name . '/' . __FUNCTION__); $this->template->content = $content; $this->template->content->products = $products; } catch (MyRuntimeException $ex) { $return_struct['status'] = 0; $return_struct['code'] = $ex->getCode(); $return_struct['msg'] = $ex->getMessage(); //TODO 异常处理 //throw $ex; if ($this->is_ajax_request()) { $this->template->content = $return_struct; } else { $this->template->return_struct = $return_struct; $content = new View('info'); $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->request_data = $request_data; //* 返回结构体绑定 */ $this->template->content->return_struct = $return_struct; } } }
static function install() { $db = Database::instance(); $db->query("CREATE TABLE IF NOT EXISTS {products} (\n `id` int(9) NOT NULL auto_increment,\n `name` TEXT NOT NULL,\n `cost` DECIMAL(10,2) default 0,\n `description` varchar(1024),\n `postage_band_id` int(9) default 1,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE IF NOT EXISTS {product_overrides} (\n `id` int(9) NOT NULL auto_increment,\n `item_id` int(9) NOT NULL,\n `none` BOOLEAN default false,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE IF NOT EXISTS {item_products} (\n `id` int(9) NOT NULL auto_increment,\n `product_override_id` int(9) NOT NULL,\n `product_id` int(9) NOT NULL,\n `include` BOOLEAN default false,\n `cost` DECIMAL(10,2) default -1,\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE IF NOT EXISTS {postage_bands} (\n `id` int(9) NOT NULL auto_increment,\n `name` TEXT NOT NULL,\n `flat_rate` DECIMAL(10,2) default 0,\n `per_item` DECIMAL(10,2) default 0,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;"); postage_band::create("No Postage", 0, 0); product::create("4x6", 5, "4\"x6\" print", 1); product::create("8x10", 25, "8\"x10\" print", 1); product::create("8x12", 30, "8\"x12\" print", 1); module::set_version("basket", 2); }
function bill_checkout($amount, $invoice, $currency_iso, $acct_fields, $total_recurring = false, $recurr_bill_arr = false) { # Get the regular period for this subscription: $sched = $recurr_bill_arr[0]["recurr_schedule"]; if ($sched == 0) { $rec_period = '7'; } elseif ($sched == 1) { $rec_period = '30'; } elseif ($sched == 2) { $rec_period = '91'; } elseif ($sched == 3) { $rec_period = '182'; } elseif ($sched == 4) { $rec_period = '365'; } elseif ($sched == 5) { return false; } $url = "https://www.moneybookers.com/app/payment.pl"; # Get the next bill date for this subscription: if ($recurr_bill_arr[0]["recurr_type"] == "1") { # Pro-rate billing: include_once PATH_MODULES . 'product/product.inc.php'; $product = new product(); $arr = $product->recurrDates($recurr_bill_arr[0]["recurr_schedule"], $recurr_bill_arr[0]["recurr_weekday"], $recurr_bill_arr[0]["recurr_week"]); $rec_start_date = date("d/m/Y", $arr["end"]); $end = $arr["end"] + 86400 * 365 * 10; $rec_end_date = date("d/m/Y", $end); $vals = array(array('pay_to_email', $this->cfg['account']), array('detail1_description', "Payment For Invoice No. " . $invoice), array('amount', $amount), array('currency', $currency_iso), array('status_url', $this->return_url), array('return_url', $this->success_url . $invoice), array('cancel_url', $this->decline_url . $invoice), array('firstname', $acct_fields["first_name"]), array('lastname', $acct_fields["last_name"]), array('address', $acct_fields["address1"]), array('postal_code', $acct_fields["zip"]), array('city', $acct_fields["city"]), array('state', $acct_fields["state"]), array('transaction_id', $invoice), array('rec_amount', $total_recurring), array('rec_start_date', $rec_start_date), array('rec_end_date', $rec_end_date), array('rec_period', $rec_period)); } else { # Bill on anniversary: $rec_start_date = date("d/m/Y", time()); $end = time() + 86400 * 365 * 10; $rec_end_date = date("d/m/Y", $end); $vals = array(array('pay_to_email', $this->cfg['account']), array('detail1_description', "Payment For Invoice No. " . $invoice), array('amount', $amount), array('currency', $currency_iso), array('status_url', $this->return_url), array('return_url', $this->success_url), array('cancel_url', $this->decline_url), array('firstname', $acct_fields["first_name"]), array('lastname', $acct_fields["last_name"]), array('address', $acct_fields["address1"]), array('postal_code', $acct_fields["zip"]), array('city', $acct_fields["city"]), array('state', $acct_fields["state"]), array('transaction_id', $invoice), array('rec_amount', $total_recurring), array('rec_start_date', $rec_start_date), array('rec_end_date', $rec_end_date), array('rec_period', $rec_period)); } $this->post_vars($url, $vals); return true; }
public static function get_list($_FORM = array()) { $filter = product::get_list_filter($_FORM); $debug = $_FORM["debug"]; $debug and print "\n<pre>_FORM: " . print_r($_FORM, 1) . "</pre>"; $debug and print "\n<pre>filter: " . print_r($filter, 1) . "</pre>"; if (is_array($filter) && count($filter)) { $f = " WHERE " . implode(" AND ", $filter); } // Put the inactive ones down the bottom. $f .= " ORDER BY productActive DESC, productName"; $taxName = config::get_config_item("taxName"); $query = prepare("SELECT * FROM product " . $f); $db = new db_alloc(); $db->query($query); while ($row = $db->next_record()) { $product = new product(); $product->read_db_record($db); $row["taxName"] = $taxName; $rows[] = $row; } return $rows; }
public function load($iID) { // open $oConnection = new Connection(); // extract $sSQL = "SELECT TypeID, TypeName, Description, DisplayOrder\n\t\tFROM tbproducttype\n\t\tWHERE TypeID=" . $iID; $oResult = $oConnection->query($sSQL); // fetch $aCategory = $oConnection->fetch_array($oResult); $this->iTypeID = $aCategory["TypeID"]; $this->sTypeName = $aCategory["TypeName"]; $this->sDescription = $aCategory["Description"]; $this->iDisplayOrder = $aCategory["DisplayOrder"]; // load products under the category $sSQL = "SELECT ProductID\n\t\tFROM tbproduct\n\t\tWHERE TypeID=" . $iID; $oResult = $oConnection->query($sSQL); while ($aRow = $oConnection->fetch_array($oResult)) { $oProduct = new product(); $oProduct->load($aRow["ProductID"]); $this->aProducts[] = $oProduct; } // close $oConnection->close_connection(); }
public function store(Request $request) { $this->validate($request, ['name' => 'required|max:50', 'content' => 'required|max:255', 'abstract' => 'required|max:70', 'price' => 'required|numeric', 'category_at' => 'numeric', 'quantity' => 'numeric', 'published_at' => 'required|date_format:d-m-Y', 'status' => 'in:opened,closed', 'thumbnail' => 'image|max:6000']); $product = product::create($request->all()); $product->tags()->attach($request->input('tags')); //gestion de l'image dans la page create if (!is_null($request->file('thumbnail'))) { $im = $request->file('thumbnail'); $ext = $im->getClientOriginalExtension(); $uri = str_random(12) . '.' . $ext; $im->move(env('UPLOAD_PATH', './uploads'), $uri); Picture::create(['uri' => $uri, 'type' => $ext, 'size' => $im->getClientSize(), 'product_id' => $product->id]); } return redirect()->intended('product'); }
public static function detail() { //get customers $detail['expense_account_all'] = expenseaccount::get_all(); //get customers $detail['customer'] = customer::get(); $detail['customer_all'] = customer::get_all(); //get billers $detail['biller_all'] = biller::get_all(); //get invoices $detail['invoice_all'] = invoice::get_all(); //get products $detail['product_all'] = product::get_all(); return $detail; }
function get_cha() { if ($_GET['module'] == 'product') { if (intval($_GET['cha']) > 0) { return intval($_GET['cha']); } elseif (intval($_GET['cat']) > 0) { $cat = new category_pro(); $row = $cat->detail($_GET['cat']); return $row['cha_id']; } elseif (intval($_GET['id']) > 0) { $pro = new product(); $row = $pro->detail('cha_id', $_GET['id']); return $row['cha_id']; } } else { return 0; } }
static function install() { $db = Database::instance(); $db->query("CREATE TABLE IF NOT EXISTS {products} (\n `id` int(9) NOT NULL auto_increment,\n `name` TEXT NOT NULL,\n `cost` DECIMAL(10,2) default 0,\n `description` varchar(1024),\n `postage_band_id` int(9) default 1,\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE IF NOT EXISTS {product_overrides} (\n `id` int(9) NOT NULL auto_increment,\n `item_id` int(9) NOT NULL,\n `none` BOOLEAN default false,\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE IF NOT EXISTS {item_products} (\n `id` int(9) NOT NULL auto_increment,\n `product_override_id` int(9) NOT NULL,\n `product_id` int(9) NOT NULL,\n `include` BOOLEAN default false,\n `cost` DECIMAL(10,2) default -1,\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE IF NOT EXISTS {postage_bands} (\n `id` int(9) NOT NULL auto_increment,\n `name` TEXT NOT NULL,\n `flat_rate` DECIMAL(10,2) default 0,\n `per_item` DECIMAL(10,2) default 0,\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE IF NOT EXISTS {orders} (\n `id` int(9) NOT NULL auto_increment,\n `status` int(9) DEFAULT 0,\n `name` varchar(1024),\n `email` varchar(1024),\n `cost` DECIMAL(10,2) default 0,\n `method` int(9) DEFAULT 0,\n `text` TEXT NOT NULL,\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE IF NOT EXISTS `ipn_messages` (\n `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n `date` int(11) NOT NULL,\n `key` varchar(20) NOT NULL,\n `txn_id` varchar(20) NOT NULL,\n `status` varchar(20) NOT NULL,\n `success` bool default false,\n `text` text,\n PRIMARY KEY (`id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); postage_band::create("No Postage", 0, 0); product::create("4x6", 5, "4\"x6\" print", 1); product::create("8x10", 25, "8\"x10\" print", 1); product::create("8x12", 30, "8\"x12\" print", 1); basket::setPaymentDetails("<p>Use the following options to pay for this order.</p>\n<p>Send a chequre to..</p>\n<p>Visit the shop..</p>\n<p>By using internet banking..</p>"); basket::setOrderPrefix("ORDER"); basket::setOrderCompletePage("<p>Your order number is %order_number. To pay for this order please either:</p>\n<p> - Send a cheque for %total_cost to with reference %order_number..</p>\n<p> - Visit the shop and quote the order %order_number..</p>\n<p> - Transfer %total_cost using internet banking with reference %order_number..</p>\n<p>Order will be processed as soon as payment is received. You should receive an e-mail with your order details shortly.</p>"); basket::setOrderCompleteEmail("Hi %name,\n\nThank you for your order the order details are below. To pay for this order please either:\n\n- Send a cheque for %total_cost to with reference %order_number..\n- Visit the shop and quote the order %order_number..\n- Transfer %total_cost using internet banking with reference %order_number..\n\nOrder will be processed as soon as payment is received. For order pick-ups please visit..\n\nOrder Details\n-------------\n%order_details\n\nThanks"); basket::setOrderCompleteEmailSubject("Photography Order %order_number"); module::set_version("basket", 5); }
public function update($params = array()) { global $db; if (isset($params['id'])) { $product = new product($params['id']); } // Save the event info to the eventregistration table # $event = new expRecord(); # $event->tablename = 'eventregistration'; $event->eventdate = datetimecontrol::parseData('eventdate', $params); $event->event_starttime = datetimecontrol::parseData('event_starttime', $params) + $event->eventdate; $event->event_endtime = datetimecontrol::parseData('event_endtime', $params) + $event->eventdate; $event->signup_cutoff = datetimecontrol::parseData('signup_cutoff', $params); $event->id = empty($product->product_type_id) ? null : $product->product_type_id; if (!empty($event->id)) { $db->updateObject($event, 'eventregistration'); } else { $event->id = $db->insertObject($event, 'eventregistration'); } $params['product_type_id'] = $event->id; parent::update($params); }
function get_products() { include_once 'product.php'; $obj = new product(); if (!$obj->connect()) { $json = '{"status":2, "products":{}}'; echo $json; exit; } if ($obj->get_products()) { $row = $obj->fetch(); $length = $obj->get_num_rows(); // Products as a set $json = '{"status":0, "products":{'; for ($i = 0; $i < $length; $i++) { $bcode = $row['PRODUCT_BARCODE']; $json = $json . '"' . $bcode . '":' . json_encode($row); $row = $obj->fetch(); if ($i < $length - 1) { $json = $json . ','; } } $json = $json . '}}'; // Products as an array // $json='{"status":0, "products":['; // for($i=0; $i<$length; $i++){ // // $bcode = $row['PRODUCT_BARCODE']; // $json=$json.'{"'.$bcode.'":'.json_encode($row).'}'; // $row=$obj->fetch(); // if($i<$length-1){ // $json=$json.','; // } // } // $json=$json.']}'; echo $json; // $d = json_decode($json); // print_r($d); } else { $json = '{"status":1, "products":{}}'; echo $json; } }
public function edit_product_form($id) { $product = ORM::factory("product", $id); if (!$product->loaded()) { throw new Kohana_404_Exception(); } $form = product::get_edit_form_admin($product); print $form; }