芝麻web文件管理V1.00
编辑当前文件:/home/sditechnicalteam/socialsolargreens.pk/controller/ProductController.php
con,$Product); return $data; } public function ProductTypeList() { $Product = "SELECT * FROM productstype ORDER BY Id DESC LIMIT 150"; $data = mysqli_query($this->con,$Product); return $data; } public function CreateProductsType($Product) { //print_r($Product); if(isset($Product['Id']) && !empty($Product['Id'])){ $q2 = "UPDATE productstype SET TypeName='".$Product['TypeName']."' WHERE Id='".$Product['Id']."'"; if (mysqli_query($this->con, $q2)) { return 'Success'; } else{ return "Error Code [321] : " . mysqli_error($this->con); } }else{ $q2 = "INSERT INTO ProductsType (TypeName) VALUES ('".$Product['TypeName']."')"; if (mysqli_query($this->con, $q2)) { return 'Success'; } else{ return "Error Code [321] : " . mysqli_error($this->con); } } die; } public function CreateProduct($Product) { //print_r($Product); if(isset($Product['Id']) && !empty($Product['Id'])){ $q2 = "UPDATE products SET Name='".$Product['Name']."', Watt='".$Product['Watt']."', TypeId='".$Product['TypeId']."', Cp='".$Product['Cp']."', Sp='".$Product['Sp']."', ReorderLevel='".$Product['ReorderLevel']."', OpStock='".$Product['OpStock']."' WHERE Id='".$Product['Id']."'"; if (mysqli_query($this->con, $q2)) { return 'Success'; } else{ return "Error Code [321] : " . mysqli_error($this->con); } }else{ $q2 = "INSERT INTO products (Name, Watt, TypeId, Cp, Sp, ReorderLevel, OpStock, ProductImage) VALUES ('".$Product['Name']."', '".$Product['Watt']."', '".$Product['TypeId']."', '".$Product['Cp']."', '".$Product['Sp']."', '".$Product['ReorderLevel']."', '".$Product['OpStock']."', 'NULL')"; if (mysqli_query($this->con, $q2)) { return 'Success'; } else{ return "Error Code [321] : " . mysqli_error($this->con); } } die; } public function Save_pt($Products) { } public function Edit($Id = '') { if(!empty($Id)){ $Product = "select * from ProductsType where Id = $Id ORDER BY Id DESC"; $d = mysqli_query($this->con, $Product); // print_r($d); if ($d->num_rows > 0) { $data = mysqli_fetch_assoc($d); return $data; } else{ return "Error Code [521] : " . mysqli_error($this->con); } } } public function Edit_pt($Id = '') { if(!empty($Id)){ $Product = "select * from ProductsType where Id = $Id ORDER BY Id DESC"; $d = mysqli_query($this->con, $Product); // print_r($d); if ($d->num_rows > 0) { $data = mysqli_fetch_assoc($d); return $data; } else{ return "Error Code [521] : " . mysqli_error($this->con); } } } public function Delete_pt($Id = '') { // if(!empty($Id)){ // $Product = "select * from ProductsType where Id = $Id"; // $d = mysqli_query($this->con, $Product); // // print_r($d); // if ($d->num_rows > 0) { // $data = mysqli_fetch_assoc($d); // return $data; // } else{ // return "Error Code [521] : " . mysqli_error($this->con); // } // } } public function Edit_p($Id = '') { if(!empty($Id)){ $Product = "select Products.Id as Id , Products.Name as Name, Products.Watt as Watt, ProductsType.TypeName as TypeName, Products.Cp as Cp, Products.Sp as Sp, Products.ReorderLevel as ReorderLevel, Products.OpStock as OpStock, Products.ProductImage as ProductImage from Products join ProductsType on Products.TypeId = ProductsType.Id WHERE Products.Id = '".$Id."' ORDER BY id DESC LIMIT 250"; $d = mysqli_query($this->con, $Product); // print_r($d); if ($d->num_rows > 0) { $data = mysqli_fetch_assoc($d); return $data; } else{ return "Error Code [521] : " . mysqli_error($this->con); } } } public function Delete_p($Id = '') { // if(!empty($Id)){ // $Product = "select * from ProductsType where Id = $Id"; // $d = mysqli_query($this->con, $Product); // // print_r($d); // if ($d->num_rows > 0) { // $data = mysqli_fetch_assoc($d); // return $data; // } else{ // return "Error Code [521] : " . mysqli_error($this->con); // } // } } }