| Server IP : 162.214.74.102 / Your IP : 216.73.217.114 Web Server : Apache System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64 User : lrsys ( 1015) PHP Version : 5.6.40 Disable Function : exec,passthru,shell_exec,system MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/lrsys/www/lrsys_apps/hering/application/plugins/module_teammanagement/models/ |
Upload File : |
<?php
include_once __DIR__ . "/../../../autoload/My_Model.php";
include_once __DIR__ . "/../factories/ProductFactory.php";
class ProductModel extends My_Model {
/**
* @var string
*/
public $table = 'module_teammanagement_product';
public function createProduct($data) {
$product = self::create();
ProductFactory::create($data, $product, true);
$product->save();
return $product;
}
public function updateProduct($data, $product) {
ORM::for_table($this->table)->create($product);
ProductFactory::create($data, $product);
$product->save();
return $product;
}
public function updateSituation($c,$situation) {
$c->situation = $situation==1?1:0;
$c->save();
return $c;
}
public function deleteProduct($product) {
if (is_file('application/plugins/module_teammanagement/uploads/product/' . $product->id . "/" . $product->image)) {
//remove
unlink('application/plugins/module_teammanagement/uploads/product/' . $product->id . "/" . $product->image);
}
ORM::for_table($this->table)->create($product);
$product->delete();
return $product;
}
//traz o registro com dados do join
public function getOneWithNames($id) {
$registers = ORM::for_table($this->table)
->raw_query(" SELECT m.*,s.account as account_branch FROM module_teammanagement_product m "
. "JOIN crm_accounts s ON(s.id=m.store_id) "//pega o nome da filial
. " WHERE m.id=" . $id)
->find_many();
return count($registers) > 0 ? $registers[0] : false;
}
public function getProductsStore($storeId) {
$registers = ORM::for_table($this->table)
->raw_query(" SELECT m.* FROM module_teammanagement_product m "
. " WHERE m.situation=1 AND m.qty>=1 AND m.store_id=" . $storeId)
->find_many();
return $registers;
}
}