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/  Your IP : 172.18.0.1   [ Reverse IP ]
Web Server : Apache/2.4.38 (Debian)
System : Linux a1822d00732a 4.15.0-39-generic #42-Ubuntu SMP Tue Oct 23 15:48:01 UTC 2018 x86_64
User : www-data ( 33)
PHP Version : 7.1.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Domains : 0 Domains
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/html/app/model/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /var/www/html/app/model/PriceProfileRepository.php
<?php

namespace Promoteus;

use App\Presenters\BasePresenter;
use http\Exception;
use Nette\Utils\ArrayHash;
use Tracy\Debugger;

/**
 * Table "price_profile"
 */
class PriceProfileRepository extends Repository
{
    protected $tableName = 'price_profile';
    private $logFile = "admin-priceProfileRepository";

    const sizes = [1, 50, 100, 200, 300, 500, 700, 1000, 2000, 3000, 5000, 7000, 10000,];


    /**
     * @param ArrayHash $values
     * @param null|string $arrayIndex
     * @param bool $skipNonEmpty
     * @return mixed|ArrayHash
     */
    static public function setPriceAutomatic(ArrayHash &$values, ?string $arrayIndex = null, bool $skipNonEmpty = true)
    {
        $sizes = PriceProfileRepository::sizes;
        array_shift($sizes);
        if ($arrayIndex !== null) {
            $_values = $values[$arrayIndex];
        } else {
            $_values = $values;
        }
        $koeficient = (
                floatval($_values[$sizes[count($sizes) - 1]])
                -
                floatval($_values[$sizes[0]])
            ) / (count($sizes) - 1);
        $current_value = $_values[array_shift($sizes)];
        array_pop($sizes);
        foreach ($sizes as $size) {//zacinam z prvku index 1. 0 a posledni byli odebrany
            if (!empty($_values->{$size}) && $skipNonEmpty) {
                continue;
            }
            $_values[$size] = $current_value = round(($current_value + $koeficient), 2);
        }
        if ($arrayIndex !== null) {
            $values[$arrayIndex] = $_values;
        } else {
            $values = $_values;
        }
        return $_values;
    }

    /**
     * @param ArrayHash $values
     * @param $id_category
     * @param $id_profile
     * @param null $rename
     * @param null $coefficient
     */
    public function saveOrInsert(ArrayHash $values, $id_category, $id_profile, $rename = null, $coefficient = null)
    {
        //existuje již záznam?
        $result = $this->db->query("SELECT price_profile_category.*, COUNT(*) count FROM price_profile_category WHERE id_profile = ? AND id_category= ?", $id_profile, $id_category)->fetch();
        //add to values
        $values['id_profile'] = $id_profile;
        $values['id_category'] = $id_category;

        if ($result->count !== 0) {
            $queryVals = '';
            foreach ($values as $key => $item) {
                $queryVals .= " `$key` = " . ($item ?: 0) . ',';
            }
            $queryVals = rtrim($queryVals, ',');
            $this->db->query("UPDATE price_profile_category SET $queryVals WHERE id_profile = ? AND id_category= ?", $id_profile, $id_category);

            $priceProfile = $this->db->table('price_profile')->get($id_profile);
            if ($rename) $priceProfile->update(['name' => $rename]);
            if ($coefficient) $priceProfile->update(['coefficient' => $coefficient]);

            /*$name = $this->db->query("SELECT name FROM price_profile WHERE id=?", $id_profile)->fetch();
            //změna jména price profilu
            if ($rename != $name) {
                $this->db->query('UPDATE price_profile SET name=? WHERE id = ?', $rename, $id_profile);
            }*/
        } else {
            //insert price_profile
            $this->db->query('INSERT INTO price_profile_category (' .
                implode(', ',
                    array_map(function ($item) {
                        return "`$item`";
                    },
                        array_keys((array)$values))) .
                ') VALUES (' . implode(',', array_values((array)$values)) . ')');
        }
    }

    //vrátí defaultní hodnoty
    public function getProfileValues(int $id_profile)
    {
        //name from table price_profile
        $price_profile = $this->getById($id_profile);  //$price_profile->name;

        $result = $this->db->query("SELECT price_profile_category.*, category.code, category.name_" . BasePresenter::getLanguageData() . " AS name FROM price_profile_category 
			LEFT JOIN category ON category.id=price_profile_category.id_category 
			WHERE id_profile=?", $id_profile)->fetchAll();


        //new object
        $foo = [];
        $foo['name'] = $price_profile->name;
        //přirážky pro potisk
        $foo['ffp_50'] = $price_profile->ffp_50;

        foreach ($result as $value) {
            foreach (self::sizes as $size) {
                $foo[$value->code][$size] = $value->{$size};
            }
            /*$foo[$value->code] = array('50' => $value->{50}, '100' => $value->{100}, '200' => $value->{200}, '300' => $value->{300}, '500' => $value->{500}, '700' => $value->{700},
                '1000' => $value->{1000}, '2000' => $value->{2000}, '3000' => $value->{3000}, '5000' => $value->{5000}, '7000' => $value->{7000}, '10000' => $value->{10000});*/
        }

        return $foo;

    }

    //kompletní smazání profilu
    public function deleteProfile($id_profile)
    {
        //smazání profilu
        $this->getById($id_profile)->delete();

        //smazání všech hodnot z DB
        $this->db->query("DELETE FROM price_profile_category WHERE id_profile = $id_profile");

        $this->deleteSellPricesByProfile($id_profile);
    }

    public function saveFixedPrice($values)
    {
		$this->deleteSellPrices($values['id_profile'], $values['product_code']);

        //existence produktu
        $result = $this->db->query("SELECT COUNT(*) count FROM product WHERE code='" . $values['product_code'] . "'")->fetch();
        if ($result->count === 0) {
            $result = $this->db->query("SELECT COUNT(*) count FROM product_altus WHERE code='" . $values['product_code'] . "'")->fetch();
        }
        //existence kombinace
        if (!$values['id_capacity']) $values['id_capacity'] = 0;
        if ($result->count != 0) {
            $result2 = $this->db->query("SELECT COUNT(*) count FROM price_profile_fixed WHERE product_code='" . $values['product_code'] . "' AND id_capacity=" . $values['id_capacity'] . " AND id_profile=" . $values['id_profile'])->fetch();
            if ($result2->count == 0) {
                if ($this->db->query('INSERT INTO price_profile_fixed ?', $values)) {
                    return 'saved';
                } else {
                    return 'unsaved';
                }
            } else {
                if ($this->saveFixedPriceUpdate($values, $values['id_profile'], $values['product_code'], $values['id_capacity'])) {
                    return 'saved';
                } else {
                    return 'unsaved';
                }
                //return 'isexist';
            }

        } else {
            return "noproduct";
        }
    }

    public function saveFixedPriceUpdate($values, $id_profile, $product_code, $id_capacity)
    {
        //update
        $queryVals = '';
        foreach ($values as $key => $item) {
            $item = $item ?: 0;
            if ($key === 'product_code') {
                $queryVals .= " `$key` = '$item',";
                continue;
            }
            $queryVals .= " `$key` = $item,";
        }
        $queryVals = rtrim($queryVals, ',');

        $result = $this->db->query("UPDATE price_profile_fixed SET $queryVals WHERE id_capacity=" . $id_capacity . ' AND id_profile=' . $id_profile . ' AND product_code="' . $product_code . '"');

        $this->deleteSellPrices($id_profile, $product_code);

        return $result;
    }

    public function existsFixedPrice($code, $idCapacity, $groups)
    {
        $exists = false;

        foreach ($groups as $group) {
            $result = $this->db->query("SELECT COUNT(*) count FROM price_profile_fixed WHERE product_code='" . $code . "' AND id_capacity=" . $idCapacity . " AND id_profile=" . $group)->fetch();

            if ($result->count > 0) {
                $exists = true;
            }
        }

        if ($exists) {
            return 'exists';
        }

        return 'noprice';
    }

    public function getProfileFixedPrices($id)
    {
        $result = $this->db->query("SELECT * FROM price_profile_fixed WHERE id_profile=$id ORDER BY product_code ASC")->fetchAll();

        //název kapacity
        foreach ($result as $key => $value) {
            $id_cap = $value->id_capacity;
            $result2 = $this->db->query("SELECT name FROM list_capacity WHERE id=$id_cap")->fetch();

            $result[$key]->capacity = $result2['name'];
        }
        return $result;
    }

    public function getFixed($id)
    {
        return $this->db->query("SELECT * FROM price_profile_fixed WHERE id=$id")->fetch();
    }

    public function deleteFixed($id)
    {
		$deletedFixed = $this->db->query("SELECT * FROM price_profile_fixed WHERE id = $id")->fetch();
		$this->deleteSellPrices($deletedFixed['id_prodfile'], $deletedFixed['product_code']);

		$this->db->query("DELETE FROM price_profile_fixed WHERE id = $id");
    }

    public function deleteFixedAll($code)
    {
        $this->db->query('DELETE FROM price_profile_fixed WHERE product_code = "'.$code.'"');

        $this->deleteSellPricesByProduct($code);
    }

    public function deleteSellPrices($id_profile, $product_code)
    {
        $this->db->query('DELETE FROM product_sell_prices WHERE price_profile_id='.$id_profile.' AND product_code="'.$product_code.'"');
    }

    public function deleteSellPricesByProfile($id_profile)
    {
		$this->db->query("DELETE FROM price_profile_fixed WHERE id_profile = $id_profile");
		$this->db->query("DELETE FROM product_sell_prices WHERE price_profile_id = $id_profile");
	}

    public function deleteSellPricesByProduct($product_code)
    {
        $this->db->query('DELETE FROM product_sell_prices WHERE product_code="'.$product_code.'"');
    }

    //duplikace
    public function duplicate($id_profile)
    {

        //Debugger::barDump($this->getProfileFixedPrices($id_profile));
        //duplikace profilu
        $this->db->beginTransaction();
        $row = $this->db->table('price_profile')->get($id_profile)->toArray();
        unset($row['id']);
        $row['name'] = $row['name'] . '(kopie)';
        $newProfile = $this->db->table('price_profile')->insert($row);
        $id_profile_new = $newProfile->id;

        //duplikace dat profilu
        $data = $this->db->query("SELECT * FROM price_profile_category WHERE id_profile=$id_profile")->fetchAll();
        foreach ($data as $value) {
            unset($value->id);
            $value->id_profile = (int)$id_profile_new;
            $this->db->table('price_profile_category')->insert($value);
        }
        unset($data);
        //duplikace fixních cen profilu
        $data = $result = $this->db->query("SELECT * FROM price_profile_fixed WHERE id_profile=?", $id_profile)->fetchAll();
        foreach ($data as $row) {
            unset($row->id);
            unset($row->id_profile);
            $row->id_profile = (int)$id_profile_new;
            $this->db->table('price_profile_fixed')->insert($row);
        }
        $this->db->commit();

    }


    public function saveFeesForPrint($values, $id)
    {
        foreach ($values as $key => $value) {
            if (empty($value)) {
                $values[$key] = null;
            }
        }
        //uložení přirážek k potiskům a finishingu
        if ($this->db->query('UPDATE price_profile SET ? WHERE id=' . $id, $values)) {
            return true;
        } else return false;
    }

    public function getPriceProfile($id)
    {
        return $this->db->query('SELECT * FROM price_profile WHERE id = ' . $id)->fetch();
    }


    /**
     * @param $category_values
     * @param $id_profile
     * @return int
     */
    public function updateImportedData($category_values, $id_profile)
    {
        $id_profile = intval($id_profile);
        foreach ($category_values as $id_category => $category_value) {
            try {
                $result = $this->db
                    ->table("price_profile_category")
                    ->select("*")
                    ->where("id_profile = ?", $id_profile)
                    ->where("id_category = ?", $id_category)
                    ->count();
            } catch (\Exception $e) {
                Debugger::log($e, $this->logFile);
                $result = 0;
            }
            if ($result != 0) {
                if ($category_values[$id_category]['50']) {
                    $category_value["id_profile"] = $id_profile;
                    $category_value["id_category"] = $id_category;
                    try {
                        $this->db
                            ->table("price_profile_category")
                            ->select("*")
                            ->where("id_profile", $id_profile)
                            ->where("id_category", $id_category)
                            ->delete();
                    } catch (\Exception $e) {
                        Debugger::log($e, $this->logFile);
                        return 3;
                    }
                    try {
                        $this->db
                            ->table("price_profile_category")
                            ->insert($category_value);
                    } catch (\Exception $e) {
                        Debugger::log($e, $this->logFile);
                        return 4;
                    }
                } else {
                    try {
                        $this->db
                            ->table("price_profile_category")
                            ->select("*")
                            ->where("id_profile = ?", $id_profile)
                            ->where("id_category = ?", $id_category)
                            ->delete();
                    } catch (\Exception $e) {
                        Debugger::log($e, $this->logFile);
                        return 5;
                    }
                }
            } else {
                if ($category_values[$id_category]['50']) {
                    $category_value['id_profile'] = $id_profile;
                    $category_value['id_category'] = $id_category;
                    try {
                        $this->db
                            ->table("price_profile_category")
                            ->insert($category_value);
                    } catch (\Exception $e) {
                        Debugger::log($e, $this->logFile);
                        return 6;
                    }
                }
            }
        }
        return 0;
    }

    /**
     * @param $id
     * @return \Nette\Database\Table\ActiveRow|void
     */
    function delete($id)
    {
        $this->deleteProfile($id);
    }

    public function getValuesForSelect()
    {
        $values = $this->findAll();

        $result = [];

        foreach ($values as $value)
        {
            $result[$value->id] = $value->name;
        }

        return $result;
    }
}

Anon7 - 2022
AnonSec Team