本文整理汇总了PHP中Products::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Products::save方法的具体用法?PHP Products::save怎么用?PHP Products::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products
的用法示例。
在下文中一共展示了Products::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* 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');
}
}
示例2: addmodels
public function addmodels($id)
{
if ($this->isAdminRequest()) {
//$id = $_POST['id'];
// print_r($_POST);
$rules = array('models' => 'required');
$validator = Validator::make(Input::all(), $rules);
// process the login
if ($validator->fails()) {
return Redirect::to('admin/products/' . $id . '/models')->withErrors($validator)->with('productcategory', ProductCategory::find($id))->with('models', Products::where('product_category_id', '=', $id)->get())->withInput(Input::all());
} else {
$models = Input::get('models');
$models_arr = explode(",", $models);
foreach ($models_arr as $model) {
$product_model = new Products();
$product_model->model_id = $model;
$product_model->product_category_id = $id;
$product_model->save();
}
// // redirect
Session::flash('message', 'Successfully added models.');
return Redirect::to('admin/products/' . $id . '/models');
}
//$import = importmodels('boo');
//
// $productcategory = ProductCategory::find($id);
// $models = Products::where('product_category_id','=',$id)->get();
// return View::make('admin.products.models')
// ->with('productcategory',$productcategory)
// ->with('models',$models);
// }
}
}
示例3: ProductLog
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']);
}
}
示例4: createAction
public function createAction()
{
$auth = $this->session->get('auth');
$request = $this->request;
if (!$request->isPost()) {
return $this->forward("products/index");
}
$request = $request->getPost();
$products = new Products();
$products->product_types_id = $request['product_types_id'];
$products->name = $request['name'];
$products->issuer = $request['issuer'];
$products->status = $request['status'];
$products->cycle = $request['cycle'];
$products->min = $request['min'];
$products->expected = $request['expected'];
$products->issuetime = $request['issuetime'];
$products->telephone = $request['telephone'];
$products->control = $request['control'];
$products->description = $request['description'];
$products->registrar = $auth['name'];
if ($products->save()) {
$this->flash->notice("保存成功!");
return $this->forward('products/new');
} else {
foreach ($products->getMessages() as $message) {
$this->flash->error((string) $message);
}
}
}
示例5: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$validator = Validator::make(Input::all(), Products::$rules);
if ($validator->passes()) {
$product = new Products();
$product->name = addslashes(Input::get('name'));
$product->color_id = Input::get('color');
$product->product_code = 0;
$product->sp = Input::get('sp');
$product->cp = Input::get('cp');
$product->quantity = Input::get('quantity');
$product->type_id = Input::get('type_id');
$product->unit_id = Input::get('unit_id');
$product->save();
$product->setProductCode($product);
$stock = new Stocks();
$stock->supplier_id = Input::get('supplier_id');
$stock->product_id = $product->id;
$stock->quantity = Input::get('quantity');
$stock->save();
return Redirect::route('products.index')->with('success', 'Product created successfully');
} else {
return Redirect::route('products.create')->withErrors($validator)->withInput(Input::all());
}
}
示例6: createProduct
public function createProduct($data)
{
$result = new Products();
$result->createTime = date('Y-m-d H:i:s', time());
foreach ($data as $k => $v) {
$result->{$k} = $v;
}
if ($result->save()) {
$data = array('code' => 200, 'message' => 'SUCCESS');
}
return $data;
}
示例7: saveNewProduct
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function saveNewProduct()
{
$pro_dtl = new Products();
$pro_dtl->Product_Name = Input::json('product');
$pro_dtl->Product_Description = Input::json('product_des');
$pro_dtl->Price = Input::json('price');
$pro_dtl->Image_URL = "1";
$pro_dtl->Catelog_Id = "1";
$pro_dtl->Channel_Id = Input::json('channel');
$pro_dtl->RefItemId = Input::json('ref_item_no');
$pro_dtl->SKU = Input::json('sku');
$pro_dtl->UnitWeight = Input::json('unit_weight');
$pro_dtl->Active = 1;
$pro_dtl->CREATE_TS = date("Y-m-d H:i:s");
$pro_dtl->MODIFY_TS = date("Y-m-d H:i:s");
$pro_dtl->save();
}
示例8: createAction
public function createAction()
{
$request = $this->request;
if (!$request->isPost()) {
return $this->forward("products/index");
}
$products = new Products();
$products->id = $request->getPost("id", "int");
$products->product_types_id = $request->getPost("product_types_id", "int");
$products->name = $request->getPost("name", "striptags");
$products->price = $request->getPost("price");
$products->active = $request->getPost("active");
if (!$products->save()) {
foreach ($products->getMessages() as $message) {
$this->flash->error((string) $message);
}
return $this->forward("products/new");
} else {
$this->flash->success("products was created successfully");
return $this->forward("products/index");
}
}
示例9: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//$confirmation_code = str_random(30);
$data = Input::except(array('_token'));
$rule = array('prodId' => 'required', 'pname' => 'required', 'descr' => 'required', 'location' => 'required', 'price' => 'required', 'pvat' => 'required', 'sales' => 'required', 'svat' => 'required', 'quantity' => 'required', 'swarn' => 'required');
/*$message = array(
'prodId.required' => 'Product Must Have a Serial Number',
'pname.required' => 'Product Name Required',
'descr.required' => 'Brief Short Product Description',
'price.required' => 'Enter Product price',
'pvat.required' => 'VAT for Price',
'sales.required' => 'Sales Price Required',
'svat.required' => 'VAT for sales',
'quantity.required' => 'Must enter quantity of stock',
'swarn.required' => 'Reorder level',
);*/
$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->category = Input::get('cat');
$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');
}
}
示例10: create_product_from_webform
function create_product_from_webform($username, $sessionid, $productname, $code, $website)
{
global $log;
global $adb;
global $current_user;
if (!validateSession($username, $sessionid)) {
return null;
}
require_once "modules/Users/Users.php";
$seed_user = new Users();
$user_id = $seed_user->retrieve_user_id($username);
$current_user = $seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
$adb->println("Create New Product from Web Form - Starts");
require_once "modules/Products/Products.php";
if (isPermitted("Products", "EditView") == "yes") {
$focus = new Products();
$focus->column_fields['productname'] = $productname;
$focus->column_fields['productcode'] = $code;
$focus->column_fields['website'] = $website;
$focus->column_fields['assigned_user_id'] = $user_id;
$focus->column_fields['discontinued'] = "1";
$focus->save("Products");
$adb->println("Create New Product from Web Form - Ends");
if ($focus->id != '') {
return 'Product added successfully.';
} else {
return "Product creation failed. Try again";
}
} else {
return $accessDenied;
}
}
示例11: Products
if (!isset($sugarbean->product_id) || is_null($sugarbean->product_id) || empty($sugarbean->product_id)) {
$product = new Products();
$product->account_id = $_REQUEST['account_id'];
$product->account_name = $_REQUEST['account_name'];
$product->contact_id = $_REQUEST['contact_id'];
$product->contact_name = $_REQUEST['contact_name'];
$product->name = $_REQUEST['product_name'];
$product->number = 'PRD' . $product->generate_number('number', $product->table_name);
//TO DO GENERATE NUMBER
$product->save($GLOBALS['check_notify']);
$sugarbean->product_id = $product->id;
} else {
$product = new Products();
$product->retrieve($sugarbean->product_id);
}
$sugarbean->save($GLOBALS['check_notify']);
$product->clientorder_id = $sugarbean->id;
$product->save($GLOBALS['check_notify']);
$sugarbean->save($GLOBALS['check_notify']);
if (isset($_REQUEST['add_component']) && $_REQUEST['add_component'] != "") {
$_REQUEST['return_url'] = 'index.php?module=EstimateComponents&action=EditView&return_module=' . $_REQUEST['parent_bean'] . '&add_component=true&return_id=' . $sugarbean->id . '&return_action=EditView&parent_id=' . $sugarbean->id . '&parent_name=' . $sugarbean->name . '&parent_bean=' . $_REQUEST['parent_bean'];
}
//$sugarbean->status_update('',$sugarbean->id);
$return_id = $sugarbean->id;
$productstatus = new ProductStatus();
if (isset($_REQUEST['status_action']) && !empty($_REQUEST['status_action'])) {
$productstatus->update_product_status($_REQUEST['status_action'], $sugarbean, $old_status);
} else {
$productstatus->update_product_status($_REQUEST['status'], $sugarbean, $old_status);
}
handleRedirect($return_id, 'ClientOrders');
示例12: actionImport
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionImport()
{
$model = new Products();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Products'])) {
if (!empty($_FILES)) {
$tempFile = $_FILES['Products']['tmp_name']['fileImport'];
$fileTypes = array('xls', 'xlsx');
// File extensions
$fileParts = pathinfo($_FILES['Products']['name']['fileImport']);
if (in_array(@$fileParts['extension'], $fileTypes)) {
Yii::import('ext.heart.excel.EHeartExcel', true);
EHeartExcel::init();
$inputFileType = PHPExcel_IOFactory::identify($tempFile);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($tempFile);
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
$baseRow = 2;
$inserted = 0;
$read_status = false;
while (!empty($sheetData[$baseRow]['A'])) {
$read_status = true;
//$product_id= $sheetData[$baseRow]['A'];
$name = $sheetData[$baseRow]['B'];
$measure_id = $sheetData[$baseRow]['C'];
$model2 = new Products();
//$model2->product_id= $product_id;
$model2->name = $name;
$model2->measure_id = $measure_id;
try {
if ($model2->save()) {
$inserted++;
}
} catch (Exception $e) {
Yii::app()->user->setFlash('error', "{$e->getMessage()}");
//$this->refresh();
}
$baseRow++;
}
Yii::app()->user->setFlash('success', $inserted . ' row inserted');
} else {
Yii::app()->user->setFlash('warning', 'Wrong file type (xlsx, xls, and ods only)');
}
}
$this->render('admin', array('model' => $model));
} else {
$this->render('admin', array('model' => $model));
}
}
示例13: array
$product->column_fields["productsheet"] = "";
$vendor_key = array_rand($vendor_ids);
$product->column_fields["vendor_id"] = $vendor_ids[$vendor_key];
$contact_key = array_rand($contact_ids);
$product->column_fields["contact_id"] = $contact_ids[$contact_key];
$product->column_fields["start_date"] =& create_date();
$product->column_fields["sales_start_date"] =& create_date();
$product->column_fields["unit_price"] = $unit_price;
$product->column_fields["commissionrate"] = $commission_rate;
$product->column_fields["taxclass"] = 'SalesTax';
$product->column_fields["usageunit"] = $usageunit;
$product->column_fields["qty_per_unit"] = $qty_per_unit;
$product->column_fields["qtyinstock"] = $qty_in_stock;
$product->column_fields["imagename"] = $product_image_name;
$product->column_fields["assigned_user_id"] = 1;
$product->save("Products");
$product_ids[] = $product->id;
}
//Populating HelpDesk- FAQ Data
$status_array = array("Draft", "Reviewed", "Published", "Draft", "Reviewed", "Draft", "Reviewed", "Draft", "Reviewed", "Draft", "Reviewed", "Draft");
$question_array = array("How to migrate data from previous versions to the latest version?", "Error message: The file is damaged and could not be repaired.", "A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this? If this is unexpected, it may be a virus and you should choose No when trying to add Email to vitger CRM ", "When trying to merge a template with a contact, First I was asked allow installation of ActiveX control. I accepted. After it appears a message that it will not be installed because it can't verify the publisher. Do you have a workarround for this issue ?", " Error message - please close all instances of word before using the vtiger word plugin. Do I need to close all Word and Outlook instances first before I can reopen Word and sign in?", "How to migrate data from previous versions to the latest version?", "A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this? If this is unexpected, it may be a virus and you should choose No when trying to add Email to vitger CRM ", " Error message - please close all instances of word before using the vtiger word plugin. Do I need to close all Word and Outlook instances first before I can reopen Word and sign in?", "Error message: The file is damaged and could not be repaired.", "When trying to merge a template with a contact, First I was asked allow installation of ActiveX control. I accepted. After it appears a message that it will not be installed because it can't verify the publisher. Do you have a workarround for this issue ?", " Error message - please close all instances of word before using the vtiger word plugin. Do I need to close all Word and Outlook instances first before I can reopen Word and sign in?", "How to migrate data from previous versions to the latest version?");
$answer_array = array("Database migration scripts are available to migrate from the following versions:\n\n\t1.0 to 2.0\n\n\t2.0 to 2.1\n\n\t2.1 to 3.0\n\n\t3.0 to 3.2\n\n\t3.2 to 4.0\n\n\t4.0 to 4.0.1\n\n\t4.0.1 to 4.2", "The above error message is due to version incompatibility between FPDF and PHP5. Use PHP 4.3.X version", "Published", "The above error message is displayed if you have installed the Microsoft(R) Outlook(R) E-mail Security Update. Please refer to the following URL for complete details:\n\nhttp://support.microsoft.com/default.aspx?scid=kb%3BEN-US%3B263074\n\nIf you want to continue working with vtiger Outlook Plug-in, select the Allow access for check box and select the time from drop-down box.", " Since, vtigerCRM & all plugins are open source, it is not signed up with third party vendors and IE will ask to download even though the plugin are not signed.\n\nThis message if produced by Microsoft Windows XP. I English Windows XP with the SP2 and the last updates. I told IE to accept installation of the ActiveX, but after it, this message has appeared. Provably there is a place where to tall to WinXP to not validate if the code is signed... but I don\\'t know where.\n\nIn IE from Tools->Internet Options->Security->Custom Level, there you can see various options for downloading plugins which are not signed and you can adjust according to your need, so relax your security settings for a while and give a try to vtiger Office Plugin.", "Before modifying any templates, please ensure that you don\\'t have any documents open and only one instance of word is available in your memory.");
$num_array = array(0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12);
for ($i = 0; $i < 12; $i++) {
$faq = new Faq();
$rand = array_rand($num_array);
$faq->column_fields["product_id"] = $product_ids[$i];
$faq->column_fields["faqcategories"] = "General";
$faq->column_fields["faqstatus"] = $status_array[$i];
$faq->column_fields["question"] = $question_array[$i];
$faq->column_fields["faq_answer"] = $answer_array[$i];
示例14: createAction
public function createAction()
{
if (!$this->request->isPost()) {
return $this->_forward("products/index");
}
$products = new Products();
$products->id = $this->request->getPost("id", "int");
$products->product_types_id = $this->request->getPost("product_types_id", "int");
$products->name = $this->request->getPost("name");
$products->price = $this->request->getPost("price");
$products->active = $this->request->getPost("active");
$products->name = strip_tags($products->name);
if (!$products->save()) {
foreach ($products->getMessages() as $message) {
Flash::error((string) $message, "alert alert-error");
}
return $this->_forward("products/new");
} else {
Flash::success("products was created successfully", "alert alert-success");
return $this->_forward("products/index");
}
}
示例15: deleteCategoryAction
public function deleteCategoryAction()
{
if (ApiController::access()) {
$category = new Category();
$product = new Products();
if (isset($_POST['id'])) {
$category = $category->findFirst($this->request->getPost('id'));
$products = $product->find(array("category = :category:", 'bind' => array('category' => $this->request->getPost('id'))));
} else {
die('не передан обязательный параметр id');
}
$success = $category->delete($this->request->getPost('id'));
foreach ($products as $product) {
$product->category = null;
$product->save();
}
if ($success != false) {
echo json_encode(array('error_code' => 200, 'error_desc' => 'Delete category: ' . $this->request->getPost('id')));
} else {
die('Что-то пошло не так...');
}
$this->view->disable();
}
}