| 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/leo/application/plugins/module_imobles/models/ |
Upload File : |
<?php
include_once __DIR__ . "/../../../autoload/My_Model.php";
include_once __DIR__ . "/../factories/CrmcommentsFactory.php";
class CrmcommentsModel extends My_Model
{
/**
* @var string
*/
public $table = 'module_imobles_crm_goals_comments';
public function createCrmcomments($data)
{
$crm_comments_category = self::create();
CrmcommentsFactory::create($data, $crm_comments_category,true);
$crm_comments_category->save();
return $crm_comments_category;
}
public function updateCrmcomments($data, $crm_comments_category)
{
ORM::for_table($this->table)->create($crm_comments_category);
CrmcommentsFactory::create($data, $crm_comments_category);
$crm_comments_category->save();
return $crm_comments_category;
}
public function deleteCrmcomments($crm_comments_category)
{
ORM::for_table($this->table)->create($crm_comments_category);
$now = new DateTime('now', new DateTimeZone('America/Sao_Paulo'));
$user = User::_info();
$crm_comments_category->deleted_at = $now->format('Y-m-d H:i:s');
$crm_comments_category->deleted_by = $user->id;
$crm_comments_category->save();
return $crm_comments_category;
}
public function getClientComments($clientID){
$deal = ORM::for_table('module_imobles_deals')
->where('crm_account_id', $clientID)
->where_null('deleted_at')
->order_by_desc('id')
->find_one();
if(isset($deal->id)){
$comments = ORM::for_table($this->table)
->where('crm_accounts_id', $clientID)
->where('deal_id', $deal->id)
->where_null('deleted_at')
->order_by_asc('id')
->find_many();
} else {
$comments = [];
}
return $comments;
}
public function addDealComment($clientID, $dealID, $fromClient, $comment){
$now = new DateTime('now', new DateTimeZone('America/Sao_Paulo'));
$dealComment = self::create();
$dealComment->created_at = $now->format('Y-m-d H:i:s');
$dealComment->created_by = null;
$dealComment->crm_accounts_id = $clientID;
$dealComment->deal_id = $dealID;
$dealComment->from_client = $fromClient;
$dealComment->comment = $comment;
$dealComment->save();
return $dealComment;
}
public function editDealComment($dealComment, $comment){
$now = new DateTime('now', new DateTimeZone('America/Sao_Paulo'));
$dealComment->comment = $comment;
$dealComment->updated_at = $now->format('Y-m-d H:i:s');
$dealComment->updated_by = null;
$dealComment->save();
return $dealComment;
}
public function deleteDealComment($dealComment){
$now = new DateTime('now', new DateTimeZone('America/Sao_Paulo'));
$dealComment->deleted_at = $now->format('Y-m-d H:i:s');
$dealComment->deleted_by = null;
$dealComment->save();
return $dealComment;
}
}