| Server IP : 14.225.216.240 / Your IP : 216.73.217.114 Web Server : nginx/1.20.1 System : Linux localhost.localdomain 5.14.0-596.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jun 27 16:02:33 UTC 2025 x86_64 User : taidh ( 1001) PHP Version : 8.3.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/pts/app/Module/Crm/Model/ |
Upload File : |
<?php
// phpcs:ignore
namespace App\Module\Crm\Model;
use PDO;
/**
* Sale Funnel Model
*
* @category Class
* @package App\Module\Crm\Model
* @author Phung, Truong K <truongkimphung1982@gmail.com>
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License
* @link https://pts-digital.com/ PTS Digital Technology Co.,Ltd
*/
class SaleFunnel extends Base
{
static $removed = [
];
/**
* Reformat item
*
* @param mixed $item : The element's sale funnel
*
* @return mixed $object
*/
public static function format($item)
{
$item = SaleFunnel::baseFormat($item);
SaleFunnel::props($item, self::$removed);
return $item;
}
/**
* Create a new sale funnel
* ------------------------------------------------------------
*
* @param mixed $args : SaleFunnelProduct model
* @param int $statusCode : Exception SQL
*
* @return bool
*/
public function addUpdateProduct($args, &$statusCode = 0)
{
$this->auth();
$response = false;
if (self::$authId > 0) {
$args = (object) ($args ?? []);
$customerId = (int)($args->customer_id ?? 0);
$activityId = (int)($args->activity_id ?? 0);
$opportunityId = (int)($args->opportunity_id ?? 0);
$productType = (int)($args->product_type->id ?? $args->product_type_id ?? 0);
$categoryId = (int)($args->category->id ?? $args->category_id ?? 0);
$productIds = (array)($args->product_ids ?? []);
if (count($productIds) < 1) {
$productIds = isset($args->products) ? array_column($args->products, 'id') : [];
}
$productIds = implode(',', $productIds);
$this->prepare(
'CALL sale_funnels_products_addupdate(
?,?,?,?,?,
?,?,?,?
);'
);
$this->bindParam(1, self::$appId, PDO::PARAM_INT, 20);
$this->bindParam(2, self::$authId, PDO::PARAM_INT, 20);
$this->bindParam(3, self::$authFullName, PDO::PARAM_STR, 64);
$this->bindParam(4, $customerId, PDO::PARAM_INT, 20);
$this->bindParam(5, $activityId, PDO::PARAM_INT, 20);
$this->bindParam(6, $opportunityId, PDO::PARAM_INT, 20);
$this->bindParam(7, $productIds, PDO::PARAM_STR, 512);
$this->bindParam(8, $productType, PDO::PARAM_INT, 20);
$this->bindParam(9, $categoryId, PDO::PARAM_INT, 20);
$response = $this->execute($statusCode);
} else {
$statusCode = self::FORBIDDEN;
}
return $response;
}
}