|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* FlexiPeeHP - Objekt řady pokladního pohybu. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Vítězslav Dvořák <[email protected]> |
|
6
|
|
|
* @copyright (C) 2015-2017 Spoje.Net |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace FlexiPeeHP; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Číselná řada pokladního pohybu |
|
13
|
|
|
*/ |
|
14
|
|
|
class RadaPokladniPohyb extends FlexiBeeRW |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* Evidence užitá objektem. |
|
18
|
|
|
* |
|
19
|
|
|
* @var string |
|
20
|
|
|
*/ |
|
21
|
|
|
public $evidence = 'rada-pokladni-pohyb'; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Obtain code for new Record |
|
25
|
|
|
* |
|
26
|
|
|
* @param string $code |
|
27
|
|
|
* @return string |
|
28
|
|
|
*/ |
|
29
|
|
|
public function getNextRecordCode($code = null) |
|
30
|
|
|
{ |
|
31
|
|
|
if (is_null($code)) { |
|
32
|
|
|
$code = $this->getMyKey(); |
|
33
|
|
|
} |
|
34
|
|
|
$crID = null; |
|
35
|
|
|
if (is_string($code)) { |
|
36
|
|
|
$sro = $this->performRequest($this->evidence.'/(kod=\''.$code.'\').json'); |
|
37
|
|
|
if (count($sro[$this->evidence])) { |
|
38
|
|
|
$crID = current(current($sro[$this->evidence])); |
|
39
|
|
|
} |
|
40
|
|
|
} else { |
|
41
|
|
|
$crID = $code; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
$cr = $this->performRequest($this->evidence.'/'.$crID.'.json'); |
|
45
|
|
|
$radaPokladniPohyb = current($cr[$this->evidence]); |
|
46
|
|
|
$crInfo = end($radaPokladniPohyb['polozkyRady']); |
|
47
|
|
|
|
|
48
|
|
|
$cislo = $crInfo['cisAkt'] + 1; |
|
49
|
|
|
if ($crInfo['zobrazNuly'] == 'true') { |
|
50
|
|
|
return $crInfo['prefix'].sprintf('%\'.0'.$crInfo['cisDelka'].'d', |
|
51
|
|
|
$cislo).'/'.date('y'); |
|
52
|
|
|
} else { |
|
53
|
|
|
return $crInfo['prefix'].$cislo.'/'.date('y'); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Zvedne číslo dokladu |
|
59
|
|
|
* |
|
60
|
|
|
* @param string $code |
|
61
|
|
|
* @return int číslo nového dokladu |
|
62
|
|
|
*/ |
|
63
|
|
|
public function incrementNextRecordCode($code = null) |
|
64
|
|
|
{ |
|
65
|
|
|
if (is_null($code)) { |
|
66
|
|
|
$code = $this->getMyKey(); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
if (is_string($code)) { |
|
70
|
|
|
$sro = $this->performRequest($this->evidence.'/(kod=\''.$code.'\').json'); |
|
71
|
|
|
$crID = current(current($sro[$this->evidence])); |
|
72
|
|
|
} else { |
|
73
|
|
|
$crID = $code; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
$cr = $this->performRequest($this->evidence.'/'.$crID.'.json'); |
|
77
|
|
|
$radaPokladniPohyb = current($cr[$this->evidence]); |
|
78
|
|
|
$crInfo = end($radaPokladniPohyb['polozkyRady']); |
|
79
|
|
|
|
|
80
|
|
|
$cislo = $crInfo['cisAkt'] + 1; |
|
81
|
|
|
return $cislo; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|