/**
  * 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');
     }
 }
Esempio n. 2
0
 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);
         // }
     }
 }
 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 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);
         }
     }
 }
 /**
  * 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());
     }
 }
Esempio n. 6
0
 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;
 }
 /**
  * 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();
 }
Esempio n. 8
0
 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");
     }
 }
 /**
  * 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');
     }
 }
Esempio n. 10
0
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;
    }
}
Esempio n. 11
0
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');
Esempio n. 12
0
 /**
  * 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));
     }
 }
Esempio n. 13
0
    $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];
Esempio n. 14
0
 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");
     }
 }
 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();
     }
 }
Esempio n. 16
0
 if (!empty($_FILES['pic']['name'])) {
     $attach_id = empty($id) ? "product-" . $the_memberid . "-" . ($product->getMaxId() + 1) : "product-" . $the_memberid . "-" . $id;
     $attachment->rename_file = $attach_id;
     $attachment->upload_process();
     $product->params['data']['product']['picture'] = $attachment->file_full_url;
 }
 $form_type_id = 2;
 $product->params['data']['product']['tag_ids'] = $tag->setTagId($_POST['data']['tag']);
 $product->params['data']['product']['cache_companyname'] = $companyinfo['name'];
 $product->params['data']['product']['industry_id'] = PbController::getMultiId($_POST['industry']['id']);
 $product->params['data']['product']['area_id'] = PbController::getMultiId($_POST['area']['id']);
 if (!empty($id)) {
     $item_ids = $form->Add($id, $_POST['data']['formitem'], 1, $form_type_id);
     $product->params['data']['product']['modified'] = $time_stamp;
     $product->params['data']['product']['formattribute_ids'] = $item_ids;
     $result = $product->save($product->params['data']['product'], "update", $id, null, $conditions);
 } else {
     if ($g['max_product'] && $now_product_amount >= $g['max_product']) {
         flash('one_day_max');
     }
     $product->params['data']['product']['member_id'] = $the_memberid;
     $product->params['data']['product']['company_id'] = $company_id;
     $product->params['data']['product']['created'] = $product->params['data']['product']['modified'] = $time_stamp;
     $result = $product->save($product->params['data']['product']);
     $new_id = $product->table_name . "_id";
     $product_id = $product->{$new_id};
     $item_ids = $form->Add($product_id, $_POST['data']['formitem'], 1, $form_type_id);
     if ($item_ids) {
         $pdb->Execute("UPDATE {$tb_prefix}products SET formattribute_ids='{$item_ids}' WHERE id=" . $product_id);
     }
 }
Esempio n. 17
0
<?php

require_once 'modules/Products/Products.php';
global $adb;
global $app_strings;
global $current_user;
//$adb->startTransaction();
$productname = $_REQUEST['productname'];
//$productcode = $_REQUEST['productcode'];
$price = $_REQUEST['price'];
//$catalogname = $_REQUEST['catalogname'];
//$catalogid = $_REQUEST['catalogid'];
$num = $_REQUEST['num'];
$focus = new Products();
$focus->column_fields["productname"] = $productname;
require_once 'user_privileges/seqprefix_config.php';
$focus->column_fields['productcode'] = $product_seqprefix . $focus->get_next_id();
//$focus->column_fields["productcode"] = $productcode;
$focus->column_fields["price"] = $price;
$focus->column_fields["num"] = $num;
$focus->id = "";
$focus->mode = "";
$focus->save("Products");
$return_id = $focus->id;
echo $return_id;
die;
Esempio n. 18
0
 public function addXLS($file_path)
 {
     //$file_path = './upload_dir/test.xls';
     $sheet_array = Yii::app()->yexcel->readActiveSheet($file_path);
     $current_product = null;
     foreach ($sheet_array as $row) {
         if ($this->isRowEmpty($row)) {
             continue;
         }
         if ($row['A'] != null && $row['B'] != null) {
             continue;
         }
         if ($row['A'] != null) {
             $current_product = ProductTypes::model()->findByAttributes(array('name' => $row['A']));
             if (!$current_product) {
                 $current_product = new ProductTypes();
             }
             $current_product->name = $row['A'];
             $properties = '[';
             foreach ($row as $cell) {
                 if ($cell != null && $cell != $row['A']) {
                     $properties = "{$properties}\"{$cell}\",";
                 }
             }
             $properties[strlen($properties) - 1] = ']';
             $current_product->properties = $properties;
             $objValues = json_decode($current_product->values_);
             if (!$objValues) {
                 $objValues = array();
                 $propCount = substr_count($current_product->properties, '","') + 1;
                 for ($i = 0; $i < $propCount; $i++) {
                     $objValues[$i] = array();
                 }
             }
             $current_product->values_ = json_encode($objValues);
             $current_product->save();
             continue;
         }
         if (!$current_product) {
             continue;
         }
         //$cell = $row['B'];
         $product = Products::model()->findByAttributes(array('article' => $row['B']));
         if (!$product) {
             $product = new Products();
         }
         $product->type_id = $current_product->id;
         $product->article = $row['B'];
         //$cell = next($row);
         $product->description = $row['C'];
         //$cell = next($row);
         $product->prices = "[\"{$row['D']}\";\"{$row['E']}\";\"{$row['F']}\"]";
         $values = '[';
         //$cell = $row['F'];
         //while ($cell = next($row))
         $objValues = json_decode($current_product->values_, true);
         $i = 'H';
         $nProp = 0;
         $isChanged = false;
         while ($row[$i]) {
             $values = "{$values}\"{$row[$i]}\",";
             if (is_array($objValues[$nProp]) && !in_array(strtolower($row[$i]), array_map('strtolower', $objValues[$nProp])) || !is_array($objValues[$nProp]) && $row[$i] != $objValues[$nProp]) {
                 $objValues[$nProp][] = $row[$i];
                 $isChanged = true;
             }
             $i++;
             $nProp++;
         }
         $values[strlen($values) - 1] = ']';
         $product->values_ = $values;
         if ($isChanged) {
             $current_product->values_ = json_encode($objValues, JSON_UNESCAPED_UNICODE);
             $current_product->save();
         }
         $product->save();
     }
     //$this->actionIndex();
 }
Esempio n. 19
0
        $id = intval($_POST['id']);
    }
    if (!empty($id)) {
        $attachment->rename_file = "product-" . $id;
    }
    if (!empty($vals['content'])) {
        $vals['content'] = stripcslashes($vals['content']);
    }
    if (!empty($_FILES['pic']['name'])) {
        $attachment->upload_process();
        $vals['picture'] = $attachment->file_full_url;
    }
    $vals['tag_ids'] = $tag->setTagId($_POST['data']['tag']);
    if (!empty($id)) {
        $vals['modified'] = $time_stamp;
        $result = $product->save($vals, "update", $id);
    } else {
        $vals['created'] = $vals['modified'] = $time_stamp;
        $result = $product->save($vals);
    }
    if (!$result) {
        flash();
    }
}
if (isset($_POST['recommend'])) {
    foreach ($_POST['id'] as $val) {
        $commend_now = $product->field("ifcommend", "id=" . $val);
        if ($commend_now == "0") {
            $result = $product->saveField("ifcommend", "1", intval($val));
        } else {
            $result = $product->saveField("ifcommend", "0", intval($val));
Esempio n. 20
0
 /**
  * 商品添加
  */
 public function actionCreate()
 {
     if ($_POST) {
         $Goods = new Goods();
         $ImageImage = new ImageImage();
         $goods_attributes = $this->post('Goods');
         //判断货号是否存在
         $bn_goods = Goods::model()->find('bn = :bn', array(':bn' => $goods_attributes['bn']));
         if ($bn_goods) {
             $this->message('error', '货号冲突', $this->createUrl('index'));
         }
         $goods_attributes['update_time'] = time();
         $Goods->attributes = $goods_attributes;
         if (!$Goods->save()) {
             $this->message('error', CHtml::errorSummary($Goods), $this->createUrl('index'));
         }
         $goods_id = Yii::app()->db->getLastInsertID();
         //商品图片
         $image_attributes = $this->post('Image');
         $image_attach_attributes = $this->post('ImageAttach');
         $image_ids = $this->post('ImageId');
         $result = $ImageImage->imageList($image_attributes, $image_attach_attributes, $image_ids, $goods_id);
         if (!$result) {
             $this->message('error', CHtml::errorSummary($ImageImage), $this->createUrl('index'));
         }
         //创建货品
         $product_attributes = array('goods_id' => $goods_id, 'bn' => $goods_attributes['bn'], 'price' => $goods_attributes['price'], 'cost' => $goods_attributes['cost'], 'mktprice' => $goods_attributes['mktprice'], 'name' => $goods_attributes['name'], 'weight' => $goods_attributes['weight'], 'unit' => $goods_attributes['unit'], 'store' => $goods_attributes['store'], 'freez' => 0, 'goods_type' => 'normal', 'is_default' => 'true', 'uptime' => time(), 'marketable' => 'true');
         $Product = new Products();
         $Product->attributes = $product_attributes;
         if (!$Product->save()) {
             $this->message('error', CHtml::errorSummary($Product), $this->createUrl('index'));
         }
         $this->referrer();
     }
     //商品类型
     $type_list = GoodsType::model()->findAll();
     $type_arr = array();
     if ($type_list) {
         foreach ($type_list as $v) {
             $type_arr[$v->type_id] = $v->name;
         }
     }
     //品牌
     $TypeBrand = new TypeBrand();
     $model['brand'] = $TypeBrand->type_brand();
     $model['type'] = $type_arr;
     $this->render('create', array('model' => $model));
 }