Issues (103)

src/FlexiPeeHP/SkladovyPohybPolozka.php (1 issue)

1
<?php
2
/**
3
 * FlexiPeeHP - Objekt položky skladového pohybu.
4
 *
5
 * @author     Vítězslav Dvořák <[email protected]>
6
 * @copyright  (C) 2015-2018 Spoje.Net
7
 */
8
9
namespace FlexiPeeHP;
10
11
/**
12
 * Položka skladového pohybu
13
 *
14
 * @link https://demo.flexibee.eu/c/demo/skladovy-pohyb-polozka/properties
15
 */
16
class SkladovyPohybPolozka extends RW
17
{
18
19
    use Stitky;
20
    /**
21
     * Evidence užitá objektem.
22
     *
23
     * @var string
24
     */
25
    public $evidence = 'skladovy-pohyb-polozka';
26
27
    /**
28
     * Add Items Serial Number
29
     * 
30
     * @param string  $number serial number
31
     * @param boolean $isMain main number
32
     * 
33
     * @return boolean Success
34
     */
35
    public function addSerialNumber($number, $isMain = false)
36
    {
37
        $numberBranch['kod'] = $number;
0 ignored issues
show
Comprehensibility Best Practice introduced by
$numberBranch was never initialized. Although not strictly required by PHP, it is generally a good practice to add $numberBranch = array(); before regardless.
Loading history...
38
        $crrentSerialNumbers = $this->getDataValue('vyrobniCislaPrijata');
39
        if ($isMain) {
40
            if (!empty($crrentSerialNumbers)) {
41
                foreach (array_keys($crrentSerialNumbers) as $serialNumberID) {
42
                    unset($this->data['vyrobniCislaPrijata'][$serialNumberID]['vyrobnicislohlav']);
43
                }
44
            }
45
            $numberBranch['vyrobnicislohlav'] = 1;
46
        }
47
        $this->setDataValue('mnozMj', count($crrentSerialNumbers) + 1);
48
        return $this->addArrayToBranch($numberBranch, 'vyrobniCislaPrijata');
49
    }
50
}
51