コード例 #1
0
  /**
   * 删除收藏
   */
  public function delete(){
	$model = D('Collect');
	$data['id'] = $_POST['id'];
	$vo = $model->field('id,source,sourceid')->where($data)->find();
	$data['member_id'] = $this->user['id'];
	$result = $model->where($data)->delete();
	if($result){
		$msg['error_code'] = 0;
		$msg['notice'] = '删除成功';
		if($vo['source']=='Product'){
		  update_product('collect_num',2,$vo['sourceid']);
		}
		ajaxSucReturn($msg);  
	}else{
		ajaxErrReturn('删除失败'); 	  
	}
  }
コード例 #2
0
/**  Switch Case to Get Action from controller  **/
switch ($_GET['action']) {
    case 'add_product':
        add_product();
        break;
    case 'get_product':
        get_product();
        break;
    case 'edit_product':
        edit_product();
        break;
    case 'delete_product':
        delete_product();
        break;
    case 'update_product':
        update_product();
        break;
}
/**  Function to Add Product  **/
function add_product()
{
    $data = json_decode(file_get_contents("php://input"));
    $prod_name = $data->prod_name;
    $prod_desc = $data->prod_desc;
    $prod_price = $data->prod_price;
    $prod_quantity = $data->prod_quantity;
    print_r($data);
    $qry = 'INSERT INTO product (prod_name,prod_desc,prod_price,prod_quantity) values ("' . $prod_name . '","' . $prod_desc . '",' . $prod_price . ',' . $prod_quantity . ')';
    $qry_res = mysql_query($qry);
    if ($qry_res) {
        $arr = array('msg' => "Product Added Successfully!!!", 'error' => '');
コード例 #3
0
ファイル: index.php プロジェクト: j-jm/web182
        if ($category_id === FALSE || $code == NULL || $name == NULL || $description == NULL || $price === FALSE || $discount_percent === FALSE) {
            $error = 'Invalid product data.
                      Check all fields and try again.';
            include '../../errors/error.php';
        } else {
            $categories = get_categories();
            $product_id = add_product($category_id, $code, $name, $description, $price, $discount_percent);
            $product = get_product($product_id);
            include 'product_view.php';
        }
        break;
    case 'update_product':
        $product_id = filter_input(INPUT_POST, 'product_id', FILTER_VALIDATE_INT);
        $category_id = filter_input(INPUT_POST, 'category_id', FILTER_VALIDATE_INT);
        $code = filter_input(INPUT_POST, 'code');
        $name = filter_input(INPUT_POST, 'name');
        $description = filter_input(INPUT_POST, 'description');
        $price = filter_input(INPUT_POST, 'price', FILTER_VALIDATE_FLOAT);
        $discount_percent = filter_input(INPUT_POST, 'discount_percent');
        if ($product_id === FALSE || $category_id === FALSE || $code === NULL || $name === NULL || $description === NULL || $price === FALSE || $discount_percent === FALSE) {
            $error = 'Invalid product data.
                      Check all fields and try again.';
            include '../../errors/error.php';
        } else {
            $categories = get_categories();
            update_product($product_id, $code, $name, $description, $price, $discount_percent, $category_id);
            $product = get_product($product_id);
            include 'product_view.php';
        }
        break;
}
コード例 #4
0
function update_product_content($id, $vid, $title, $description, $sku, $price, $quantity, $isbn, $list_price, $condition, $author, $publisher, $dimension, $page)
{
    $product = array('id' => $vid, "body_html" => $description, "variants" => array(array("id" => $vid, "option1" => $condition, "price" => $price, "sku" => $sku, "inventory_quantity" => $quantity, "barcode" => $isbn, "compare_at_price" => $list_price)), "options" => array(["name" => "Condition"], ["name" => "Publisher"], ["name" => "Etc"]));
    return update_product($id, $product);
}
コード例 #5
0
ファイル: editproduct.php プロジェクト: kagoji/liveproduct
?>


<?php 
if (!empty($_GET['product'])) {
    $product_info = product_info($_GET['product']);
    $product_id = $_GET['product'];
    if (!empty($product_info)) {
        if (!empty($_POST['submit'])) {
            if (!empty($_FILES['product_image']['name'])) {
                $product_image_url = image_upload();
            } else {
                $product_image_url = $product_info['product_image_url'];
            }
            if (isset($product_image_url)) {
                $update_product = update_product($product_id, $_POST['product_name'], $product_image_url, $_POST['category_id'], $_POST['unit_price']);
                if ($update_product == 1) {
                    header('Location:product.php');
                } else {
                    $errormessage = "Something wrong. Please Try Again!!";
                }
            } else {
                $errormessage = "Product Image is invalid. Please Try Again!!";
            }
        }
        $all_category = all_category();
        //for select box
        $all_product = all_product();
    } else {
        header('Location:product.php');
    }
コード例 #6
0
ファイル: product_view.php プロジェクト: husmen73/on-muhasebe
        $product['description'] = $this->input->post('description');
        $product['cost_price'] = $this->input->post('cost_price');
        $product['sale_price'] = $this->input->post('sale_price');
        $product['tax_rate'] = $this->input->post('tax_rate');
        $product['serial'] = $this->input->post('serial');
        // Have barcode?
        $this->db->where('status', '1');
        $this->db->where_not_in('id', $product['id']);
        $this->db->where('code', $product['code']);
        $query = $this->db->get('products')->result_array();
        if ($query) {
            alertbox('alert-danger', get_lang('This barcode is found in the database. Used for another product.'));
            $continue = false;
        }
        if ($continue) {
            if (update_product($product['id'], $product)) {
                alertbox('alert-success', get_lang('Operation is Successful'), '');
                $log['date'] = $this->input->post('log_time');
                $log['type'] = 'product';
                $log['title'] = get_lang('Product');
                $log['description'] = get_lang('Product card has been updated.');
                $log['other_id'] = 'product:' . $product['id'];
                add_log($log);
            } else {
                alertbox('alert-danger', get_lang('Error!'));
            }
        }
    }
}
?>
コード例 #7
0
         $upc = $v;
         continue;
     } else {
         continue;
     }
 }
 if (empty($description) or empty($upc)) {
     //or or empty($brand) or empty($sku) empty($wholesale_price) or empty($retail_price) or empty($size) ){
     echo "missing data\n";
     //: description: $description, UPC: $upc, brand: $brand, SKU: $sku, Wholesale_price: $wholesale_price, Retail_price: $retail_price, Size: $size\n";
     print_r($row);
     //exit;
     continue;
 }
 // fix wrong description field
 update_product($upc, $description);
 echo "{$upc}, ";
 continue;
 $guid = set_global_user($brand);
 $ret = set_global_user_apps($guid);
 $uid = set_production_user($brand, $guid);
 $sid = set_store($brand, $uid);
 set_users_store($sid, $uid);
 set_brand_columns($sid, $uid);
 $pid = set_product($upc, $sid, $description, $brand, $upc, $sku, $wholesale_price, $retail_price);
 set_products_pricing($pid, 'wholesale_price', $wholesale_price);
 set_products_pricing($pid, 'retail_price', $retail_price);
 //set_products_pricing($pid, 'price_floor', $map);
 $cnt++;
 if ($cnt == 3) {
     exit;
コード例 #8
0
ファイル: manage_product.php プロジェクト: picsoung/NabzFood
        $form_update_product[$value]->add('Text', 'product_portion')->label('Nombre de portions par produit')->value($infos_product['product_portion'] . ' ');
        $form_update_product[$value]->add('Text', 'product_price')->label('Prix du produit')->value($infos_product['product_price'] . ' ');
        $form_update_product[$value]->add('Text', 'product_img')->label('Image du produit')->value($infos_product['product_image']);
        $form_update_product[$value]->add('Text', 'product_health_pt')->label('Point de santé du produit')->value($infos_product['prdct_health_pt'] . ' ');
        $form_update_product[$value]->add('Text', 'product_angry_pt')->label('Point de faim du produit')->value($infos_product['prdct_angry_pt'] . ' ');
        $form_update_product[$value]->add('Text', 'product_thirst_pt')->label('Point de soif du produit')->value($infos_product['prdct_thirst_pt']) . ' ';
        $form_update_product[$value]->add('Submit', 'submit')->value('Valider');
        $form_update_product[$value]->bound($_POST);
    }
    //Errors and confirm array
    $error_update = array();
    $msg_confirm = array();
    foreach ($array_id as $value) {
        if ($form_update_product[$value]->is_valid($_POST)) {
            list($product_name, $product_cat, $product_desc, $product_qty, $product_portion, $product_price, $product_img, $product_health_pt, $product_angry_pt, $product_thirst_pt) = $form_update_product[$value]->get_cleaned_data('product_name', 'product_cat', 'product_description', 'product_qty', 'product_portion', 'product_price', 'product_img', 'product_health_pt', 'product_angry_pt', 'product_thirst_pt');
            $test_product = update_product($product_name, $product_cat, $product_desc, $product_qty, $product_portion, $product_price, $product_img, $product_health_pt, $product_angry_pt, $product_thirst_pt, $value);
            if ($test_product == true) {
                $msg_confirm[] = "Votre produit a bien était mis à jour.";
                header("Location: index.php?module=admin&action=manage_product&id=" . $_SESSION['id']);
                //Reload page
            } else {
                $error_update[] = "Erreur dans la mis à jour du produit.";
            }
            //end test_product
        }
        //end of is_valid
    }
    //end of foreach
    include PATH_VIEW . 'form_edit_product.php';
}
//end user_admin
コード例 #9
0
<?php

require_once './function.php';
update_product($_POST);
コード例 #10
0
<?php

require __DIR__ . '/../src/bootstrap_admin.php';
if (has_post()) {
    $product = get_product_by_id($_POST['product_id']);
    $updated_product = ['id' => get_from_post('product_id', $product['id']), 'name' => get_from_post('name', $product['name']), 'price' => get_from_post('price', $product['price']), 'brand' => get_from_post('brand', $product['brand']), 'description' => get_from_post('description', $product['description']), 'categories' => get_from_post('categories', $product['categories'])];
    update_product($updated_product);
    header('Location: /admin/index.php');
    die;
}
if (!array_key_exists('product_id', $_GET)) {
    header('Location: /admin/index.php');
    die;
}
$product = get_product_by_id($_GET['product_id']);
echo render_admin_template('product_form', ['title' => 'Edit product', 'product' => $product, 'user' => get_current_admin_user()]);
コード例 #11
0
ファイル: index.php プロジェクト: Cragun-Caleb/Thistleheim
                        if ($action == 'delete_category') {
                            // Deletes a category from the list
                            $category_id = filter_input(INPUT_POST, 'category_id', FILTER_VALIDATE_INT);
                            delete_category($category_id);
                            header('Location: .?action=list_categories');
                        } else {
                            if ($action == 'edit_product') {
                                $merchandise = filter_input(INPUT_POST, 'product', FILTER_VALIDATE_INT);
                                $category = filter_input(INPUT_POST, 'category', FILTER_VALIDATE_INT);
                                $pro_code = filter_input(INPUT_POST, 'product_code');
                                $pro_name = filter_input(INPUT_POST, 'product_name');
                                $pro_price = filter_input(INPUT_POST, 'list_price', FILTER_VALIDATE_FLOAT);
                                include 'product_edit.php';
                            } else {
                                if ($action == 'update_product') {
                                    $merchandise = filter_input(INPUT_POST, 'product_value', FILTER_VALIDATE_INT);
                                    $category = filter_input(INPUT_POST, 'category', FILTER_VALIDATE_INT);
                                    $pro_code = filter_input(INPUT_POST, 'code');
                                    $pro_name = filter_input(INPUT_POST, 'name');
                                    $pro_price = filter_input(INPUT_POST, 'price', FILTER_VALIDATE_FLOAT);
                                    update_product($merchandise, $category, $pro_name, $pro_code, $pro_price);
                                    header('Location: .?action=list_products');
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
コード例 #12
0
    $function = $values['function'];
}
switch ($function) {
    case 'add_product':
        include_once __DIR__ . '/products/add_product.php';
        $responseArray['response'] = add_product($values);
        $responseArray['message'] = 'Successfully added product';
        break;
    case 'get_products':
        include_once __DIR__ . '/products/get_products.php';
        $responseArray['response'] = get_products($values);
        $responseArray['message'] = 'Products successfully read';
        break;
    case 'update_product':
        include_once __DIR__ . '/products/update_product.php';
        update_product($values);
        $responseArray['message'] = 'Product successfully updated';
        break;
    case 'add_product_class':
        include_once __DIR__ . '/products/add_product_class.php';
        add_product_class($values);
        $responseArray['message'] = 'Class successfully added';
        break;
    case 'get_product_classes':
        include_once __DIR__ . '/products/get_product_classes.php';
        $responseArray['response'] = get_product_classes($values);
        $responseArray['message'] = 'Classes successfully read';
        break;
    case 'update_product_class':
        include_once __DIR__ . '/products/update_product_class.php';
        update_product_class($values);