Toggle navigation
Toggle navigation
This project
Loading...
Sign in
UT
/
ut-tex
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
redmine
2015-12-09 20:28:52 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
013058d7250f4b5cfa3d037e5bad3570ce214d6e
013058d7
1 parent
90fe72b6
Don't remember
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
663 additions
and
286 deletions
.gitignore
genpdf/genpdf.php
genpdf/lib/3dparty/Inflect
mephimemo/mephimemo.cls
mephimemo/template/request/custom.tex
mephimemo/template/request/itsupport.tex
mephimemo/template/request/lanmodern.tex
mephimemo/template/request/php.tex
mephimemo/template/request/temporary-acting.tex
mephimemo/template/request/vacation.tex
.gitignore
View file @
013058d
...
...
@@ -5,3 +5,4 @@ mephimemo/responsible.tex
mephimemo/urlqr.tex
mephimemo/memo.aux
mephimemo/memo.fdb_latexmk
*.log
...
...
genpdf/genpdf.php
View file @
013058d
...
...
@@ -4,6 +4,7 @@ require_once "lib/3rdparty/php-redmine-api/lib/Redmine/Api/AbstractApi.php";
require_once
"lib/3rdparty/php-redmine-api/lib/Redmine/Api/SimpleXMLElement.php"
;
require_once
"lib/3rdparty/php-redmine-api/lib/Redmine/Api/User.php"
;
require_once
"lib/3rdparty/php-redmine-api/lib/Redmine/Api/Issue.php"
;
require_once
"lib/3rdparty/php-redmine-api/lib/Redmine/Api/IssueCategory.php"
;
require_once
"lib/3rdparty/php-redmine-api/lib/Redmine/Api/Attachment.php"
;
require_once
"lib/3rdparty/php-redmine-api/lib/Redmine/Api/Membership.php"
;
require_once
"lib/3rdparty/php-redmine-api/lib/Redmine/Client.php"
;
...
...
@@ -86,6 +87,9 @@ Array
)
*/
$_GET
=
array_merge
(
$_GET
,
$_POST
);
//print_r ($_GET); die();
$dont_inflect_patterns
=
array
(
'/^нач\./'
,
'/^зам\./'
,
...
...
@@ -150,13 +154,90 @@ function error($str) {
exit
(
0
);
}
function
latexSpecialChars
(
$string
)
{
$string
=
str_replace
(
"
\\
textbackslash"
,
"
\\
"
,
$string
);
$string
=
str_replace
(
"
\\
"
,
"
\\
textbackslash"
,
$string
);
$map
=
array
(
"#"
=>
"
\\
#"
,
"$"
=>
"
\\
$"
,
"%"
=>
"
\\
%"
,
"&"
=>
"
\\
&"
,
"~"
=>
"
\\
~{}"
,
"_"
=>
"
\\
_"
,
"^"
=>
"
\\
^{}"
,
"{"
=>
"
\\
{"
,
"}"
=>
"
\\
}"
,
);
return
preg_replace
(
"/([\^\%~#
\$
%&_\{\}])/e"
,
"
\$
map['$1']"
,
$string
);
}
//DE base64 subdivs
if
(
isset
(
$_GET
[
'signer-subdivs'
])){
$_GET
[
'signer-subdivs'
]
=
base64_decode
(
$_GET
[
'signer-subdivs'
]);
$test
=
"Test characters: # $ % & ~ _ ^ \ { }."
;
header
(
"content-type:text/plain"
);
function
latexSpecialChars1
(
$string
)
{
$map
=
array
(
"#"
=>
"
\\
#"
,
"$"
=>
"
\\
$"
,
"%"
=>
"
\\
%"
,
"&"
=>
"
\\
&"
,
"~"
=>
"
\\
~{}"
,
"_"
=>
"
\\
_"
,
"^"
=>
"
\\
^{}"
,
"
\\
"
=>
"
\\
textbackslash"
,
"{"
=>
"
\\
{"
,
"}"
=>
"
\\
}"
,
);
return
preg_replace
(
"/([\^\%~
\\\\
#
\$
%&_\{\}])/e"
,
"
\$
map['$1']"
,
$string
);
}
function
redmine_login2id
(
$login
)
{
error_log
(
"redmine_login2id(
$login
)"
);
static
$login2id
=
array
();
if
(
empty
(
$login2id
))
{
$lines
=
split
(
"
\n
"
,
file_get_contents
(
'/home/xaionaro/redmine_users.csv'
));
foreach
(
$lines
as
&
$line
)
{
$words
=
split
(
"
\t
"
,
$line
);
$login2id
[
strtolower
(
$words
[
1
])]
=
$words
[
0
];
}
}
error_log
(
'R: '
.
$login2id
[
strtolower
(
$login
)]);
return
$login2id
[
strtolower
(
$login
)];
}
function
redmine_proj_identifier2id
(
$ident
)
{
error_log
(
"redmine_proj_identifier(
$ident
)"
);
static
$ident2id
=
array
();
if
(
empty
(
$ident2id
))
{
$lines
=
split
(
"
\n
"
,
file_get_contents
(
'/home/xaionaro/redmine_projects.csv'
));
foreach
(
$lines
as
&
$line
)
{
$words
=
split
(
"
\t
"
,
$line
);
$ident2id
[
strtolower
(
$words
[
1
])]
=
$words
[
0
];
}
}
error_log
(
'RI:'
.
$ident2id
[
strtolower
(
$ident
)]);
return
$ident2id
[
strtolower
(
$ident
)];
}
if
(
isset
(
$_GET
[
'signer-subdivs-full'
])){
$_GET
[
'signer-subdivs-full'
]
=
base64_decode
(
$_GET
[
'signer-subdivs-full'
]);
function
my_mb_ucfirst
(
$str
,
$e
=
'utf-8'
)
{
$fc
=
mb_strtoupper
(
mb_substr
(
$str
,
0
,
1
,
$e
),
$e
);
return
$fc
.
mb_substr
(
$str
,
1
,
mb_strlen
(
$str
,
$e
),
$e
);
}
$inflect
=
new
Inflect
();
...
...
@@ -167,31 +248,53 @@ foreach (array('signer', 'contact', 'user') as $key) {
if
(
!
empty
(
$_GET
[
$key
.
'-e_id'
]))
{
$e_id
=
$_GET
[
$key
.
'-e_id'
];
$employees
=
json_decode
(
file_get_contents
(
"http://cps.mephi.ru/?cmd=getemployeeinfo&e_id="
.
urlencode
(
$e_id
)
));
$employees
=
json_decode
(
file_get_contents
(
"http
s
://cps.mephi.ru/?cmd=getemployeeinfo&e_id="
.
urlencode
(
$e_id
)
));
$employee
=
((
array
)
$employees
);
$employee
=
reset
(
$employee
);
}
else
if
(
!
empty
(
$_GET
[
$key
.
'-login'
]))
{
$login
=
$_GET
[
$key
.
'-login'
];
$employees
=
json_decode
(
file_get_contents
(
"http://cps.mephi.ru/?cmd=getemployeeinfo&username="
.
urlencode
(
$login
)
));
$employees
=
json_decode
(
file_get_contents
(
"http
s
://cps.mephi.ru/?cmd=getemployeeinfo&username="
.
urlencode
(
$login
)
));
$employee
=
((
array
)
$employees
);
$employee
=
reset
(
$employee
);
}
else
continue
;
$appointments
=
array
();
$appointments
=
array
();
$subdivs
=
array
();
$subdivs_full
=
array
();
$appointments_wosubdiv
=
array
();
foreach
(
$employee
->
WORKPOSITIONS
as
$workposition
)
{
$appointments
[]
=
preg_replace
(
'/ [0-9]*.[0-9]$/'
,
''
,
$workposition
->
name
)
.
' '
.
mb_strtoupper
(
$workposition
->
subdivision
->
shortname
);
$appointments
[]
=
preg_replace
(
'/ [0-9]*.[0-9]$/'
,
''
,
$workposition
->
name
)
.
' '
.
mb_strtoupper
(
$workposition
->
subdivision
->
shortname
);
$subdivs
[]
=
$workposition
->
subdivision
->
shortname
;
$subdivs_full
[]
=
$workposition
->
subdivision
->
name
;
$appointments_wosubdiv
[]
=
preg_replace
(
'/ [0-9]*.[0-9]$/'
,
''
,
$workposition
->
name
);
}
$fullname
=
$employee
->
fullname
;
$name
=
mb_substr
(
$employee
->
firstname
,
0
,
1
)
.
'.'
.
mb_substr
(
$employee
->
middlename
,
0
,
1
)
.
'. '
.
$employee
->
lastname
;
$appointment
=
join
(
', '
,
$appointments
);
$_GET
[
$key
.
'-fullname'
]
=
$fullname
;
$_GET
[
$key
.
'-name'
]
=
$name
;
$_GET
[
$key
.
'-appointment'
]
=
$appointment
;
$_GET
[
$key
.
'-subdivs'
]
=
join
(
', '
,
$subdivs
);
$_GET
[
$key
.
'-subdivs-full'
]
=
join
(
'; '
,
$subdivs_full
);
$_GET
[
$key
.
'-appointment-wosubdiv'
]
=
join
(
', '
,
$appointments_wosubdiv
);
//$appointments_wosubdiv = split(', ', $_GET[$key.'-appointment-wosubdiv']);
}
$_GET
[
$key
.
'-fullname'
]
=
$fullname
;
$_GET
[
$key
.
'-name'
]
=
$name
;
$_GET
[
$key
.
'-appointment'
]
=
$appointment
;
//DE base64 subdivs
foreach
(
array
(
'signer'
,
'contact'
,
'user'
)
as
$key
)
{
if
(
!
empty
(
$_GET
[
$key
.
'-e_id'
]))
continue
;
if
(
isset
(
$_GET
[
$key
.
'-subdivs'
])){
$_GET
[
$key
.
'-subdivs'
]
=
base64_decode
(
$_GET
[
$key
.
'-subdivs'
]);
}
if
(
isset
(
$_GET
[
$key
.
'-subdivs-full'
])){
$_GET
[
$key
.
'-subdivs-full'
]
=
base64_decode
(
$_GET
[
$key
.
'-subdivs-full'
]);
}
}
foreach
(
array
(
'fullname'
=>
40
,
'phonenumber'
=>
20
,
'email'
=>
30
,
'appointment'
=>
40
,
'pgp-id'
=>
12
)
as
$key
=>
$space
)
{
...
...
@@ -213,10 +316,22 @@ foreach (array('signer', 'contact', 'user') as $key) {
if
(
empty
(
$_GET
[
$key_prefix
.
'-'
.
$key
.
'-fullname'
]))
$_GET
[
$key_prefix
.
'-'
.
$key
.
'-fullname'
]
=
$inflect
->
getInflectName
(
$_GET
[
$key
.
'-fullname'
],
$case
);
if
(
empty
(
$_GET
[
$key_prefix
.
'-'
.
$key
.
'-subdivs-full'
]))
{
$words
=
split
(
' '
,
$_GET
[
'signer-subdivs-full'
]);
$words
[
0
]
=
$inflect
->
getInflectNoun
(
$words
[
0
],
$case
);
$_GET
[
$key_prefix
.
'-'
.
$key
.
'-subdivs-full'
]
=
join
(
' '
,
$words
);
if
(
empty
(
$_GET
[
$key_prefix
.
'-'
.
$key
.
'-name'
]))
{
$words
=
explode
(
' '
,
$_GET
[
$key
.
'-name'
]);
$fwords
=
explode
(
' '
,
$_GET
[
$key_prefix
.
'-'
.
$key
.
'-fullname'
]);
$_GET
[
$key_prefix
.
'-'
.
$key
.
'-name'
]
=
$words
[
0
]
.
' '
.
$words
[
1
]
.
' '
.
$fwords
[
0
];
}
if
(
empty
(
$_GET
[
$key_prefix
.
'-'
.
$key
.
'-subdivs-full'
])
&&
!
empty
(
$_GET
[
$key
.
'-subdivs-full'
]))
{
$subdivs_full
=
split
(
'; '
,
$_GET
[
$key
.
'-subdivs-full'
]);
foreach
(
$subdivs_full
as
&
$subdiv_full
)
{
$words
=
split
(
' '
,
$subdiv_full
);
$words
[
0
]
=
$inflect
->
getInflectNoun
(
$words
[
0
],
$case
);
$subdiv_full
=
join
(
' '
,
$words
);
}
$_GET
[
$key_prefix
.
'-'
.
$key
.
'-subdivs-full'
]
=
$subdivs_full
;
}
if
(
empty
(
$_GET
[
$key_prefix
.
'-'
.
$key
.
'-appointment'
]))
{
...
...
@@ -229,41 +344,68 @@ foreach (array('signer', 'contact', 'user') as $key) {
}
// working with appointments
$appointments
=
split
(
', '
,
$_GET
[
$key
.
'-appointment'
]);
foreach
(
$appointments
as
&
$appointment
)
{
$matches
=
NULL
;
$ignored_ending
=
''
;
$appointment
=
preg_replace
(
$inflect_cut_patterns
,
''
,
$appointment
);
error_log
(
'Appointment: '
.
$appointment
);
foreach
(
$inflect_ignore_ending_patterns
as
$inflect_ignore_ending_pattern
)
{
if
(
preg_match
(
'/'
.
$inflect_ignore_ending_pattern
.
'$/u'
,
$appointment
,
$matches
,
PREG_OFFSET_CAPTURE
))
{
foreach
(
$matches
as
&
$match
)
{
$ignored_ending
.=
$match
[
0
];
$appointment
=
mb_substr
(
$appointment
,
0
,
-
mb_strlen
(
$match
[
0
]));
foreach
(
array
(
''
,
'-wosubdiv'
)
as
$postfix
)
{
$appointments
=
split
(
', '
,
$_GET
[
$key
.
'-appointment'
.
$postfix
]);
foreach
(
$appointments
as
&
$appointment
)
{
$matches
=
NULL
;
$ignored_ending
=
''
;
$appointment
=
preg_replace
(
$inflect_cut_patterns
,
''
,
$appointment
);
error_log
(
'Appointment'
.
$postfix
.
': '
.
$appointment
);
foreach
(
$inflect_ignore_ending_patterns
as
$inflect_ignore_ending_pattern
)
{
if
(
preg_match
(
'/'
.
$inflect_ignore_ending_pattern
.
'$/u'
,
$appointment
,
$matches
,
PREG_OFFSET_CAPTURE
))
{
foreach
(
$matches
as
&
$match
)
{
$ignored_ending
.=
$match
[
0
];
$appointment
=
mb_substr
(
$appointment
,
0
,
-
mb_strlen
(
$match
[
0
]));
}
}
}
}
$appointment
=
$inflect
->
getInflectNoun
(
$appointment
,
$case
);
$appointment
=
$inflect
->
getInflectNoun
(
$appointment
,
$case
);
$appointment
.=
$ignored_ending
;
$_GET
[
$key_prefix
.
'-'
.
$key
.
'-appointment'
]
=
$appointment
;
}
$appointment
.=
$ignored_ending
;
$_GET
[
$key_prefix
.
'-'
.
$key
.
'-appointment'
.
$postfix
]
=
$appointment
;
}
$_GET
[
$key_prefix
.
'-'
.
$key
.
'-appointment'
]
=
join
(
', '
,
$appointments
);
$_GET
[
$key_prefix
.
'-'
.
$key
.
'-appointment'
.
$postfix
]
=
join
(
', '
,
$appointments
);
}
}
}
$signer_appointment_wosubdiv_words
=
split
(
' '
,
$_GET
[
'signer-appointment-wosubdiv'
]);
$signer_subdivs_full_words
=
split
(
' '
,
$_GET
[
'of-signer-subdivs-full'
]);
error_log
(
'DDD: '
.
serialize
(
$signer_appointment_wosubdiv_words
));
error_log
(
'WWW: '
.
serialize
(
$signer_subdivs_full_words
));
if
(
$signer_appointment_wosubdiv_words
[
count
(
$signer_appointment_wosubdiv_words
)
-
1
]
===
$signer_subdivs_full_words
[
0
])
unset
(
$signer_appointment_wosubdiv_words
[
count
(
$signer_appointment_wosubdiv_words
)
-
1
]);
foreach
(
array
(
'signer'
,
'contact'
,
'user'
)
as
$key
)
{
foreach
(
array
(
''
,
'of-'
,
'to-'
)
as
$key_prefix
)
{
$appointment_w_fullsubdiv
=
array
();
$appointments_wosubdiv
=
is_array
(
$_GET
[
$key_prefix
.
$key
.
'-appointment-wosubdiv'
])
?
$_GET
[
$key_prefix
.
$key
.
'-appointment-wosubdiv'
]
:
split
(
', '
,
$_GET
[
$key_prefix
.
$key
.
'-appointment-wosubdiv'
]);
foreach
(
$appointments_wosubdiv
as
$id
=>
&
$appointment_wosubdiv
)
{
$appointment_wosubdiv_words
=
split
(
' '
,
$appointment_wosubdiv
);
$subdivs_full_words
=
split
(
' '
,
$_GET
[
'of-'
.
$key
.
'-subdivs-full'
][
$id
]);
if
(
$appointment_wosubdiv_words
[
count
(
$appointment_wosubdiv_words
)
-
1
]
===
$subdivs_full_words
[
0
])
unset
(
$appointment_wosubdiv_words
[
count
(
$appointment_wosubdiv_words
)
-
1
]);
$appointment_wosubdiv_dedup
=
join
(
' '
,
$appointment_wosubdiv_words
);
$_GET
[
'signer-appointment-wosubdiv-dedup'
]
=
join
(
' '
,
$signer_appointment_wosubdiv_words
);
if
(
$_GET
[
'of-'
.
$key
.
'-subdivs-full'
][
$id
]
==
'ректората'
)
{
$appointment_w_fullsubdiv_item
=
$appointment_wosubdiv_dedup
;
}
else
{
$appointment_w_fullsubdiv_item
=
$appointment_wosubdiv_dedup
.
' '
.
$_GET
[
'of-'
.
$key
.
'-subdivs-full'
][
$id
];
}
if
(
$appointment_w_fullsubdiv_item
==
" "
)
{
$appointment_w_fullsubdiv_item
=
str_pad
(
''
,
60
,
'_'
);
}
$appointment_w_fullsubdiv
[]
=
$appointment_w_fullsubdiv_item
;
}
$_GET
[
$key_prefix
.
$key
.
'-appointment-w-fullsubdiv'
]
=
$appointment_w_fullsubdiv
;
//join(', ', $appointment_w_fullsubdiv);
}
}
//print_r($_GET); die();
foreach
(
array
(
'work-date-end'
=>
'Срок окончания работ'
)
as
$key
=>
$descr
)
{
$_GET
[
$key
.
'-descr'
]
=
$descr
.
': '
.
...
...
@@ -292,26 +434,11 @@ foreach (array('videocheck', 'confcheck', 'webtrans', 'telebridge', 'otherconf',
//govnocode 2.0
else
{
/*
// if ($_GET['video-type'] == 'Нет')
// die('Ошибка: не выбран флажок видеосъемки');
if (isset($_GET['usermount1']) || isset($__GET['record1']))
die('Ошибка: не выбран флажок видеоконференции');
if (isset($_GET['record2']))
die('Ошибка: не выбран флажок вебтрансляции');
if (isset($_GET['usermount2']) || isset($_GET['record3']))
die('Ошибка: не выбран флажок проведения телемоста');
if (isset($_GET['otherconftext']))
die('Ошибка: не выбран флажок "Другое"');
*/
$_GET
[
$key
]
=
'Нет'
;
}
}
//Jim's simple diagnostics
//print_r($_GET);die();
$redmine_admin
=
new
Redmine\Client
(
'https://redmine.ut.mephi.ru'
,
REDMINE_LOGIN
,
REDMINE_PASSWORD
);
$me
=
NULL
;
...
...
@@ -332,15 +459,19 @@ if (isset($_GET['user-serialized'])) {
$user_drupal
=
unserialize
(
$user_drupal_serialized
);
$user_redmine
=
NULL
;
foreach
(
$redmine_admin
->
api
(
'user'
)
->
all
(
array
(
'name'
=>
split
(
'@'
,
$user_drupal
->
user_id
)[
0
]))[
'users'
]
as
&
$_user
)
{
if
(
strtolower
(
$_user
[
'login'
])
.
'@mephi.ru'
==
strtolower
(
$user_drupal
->
user_id
))
{
$username_drupal
=
strtolower
(
split
(
'@'
,
$user_drupal
->
user_id
)[
0
]);
foreach
(
$redmine_admin
->
api
(
'user'
)
->
all
(
array
(
'name'
=>
$username_drupal
))[
'users'
]
as
&
$_user
)
{
$_user
[
'login'
]
=
strtolower
(
$_user
[
'login'
]);
if
(
$_user
[
'login'
]
==
$username_drupal
)
{
$user_redmine
=
$redmine_admin
->
api
(
'user'
)
->
show
(
$_user
[
'id'
]);
break
;
}
}
if
(
is_null
(
$user_redmine
))
die
(
'Cannot find user "'
.
$user
_drupal
->
name
.
'" in Redmine'
);
die
(
'Cannot find user "'
.
$user
name_drupal
.
'" in Redmine'
);
$api_key
=
$user_redmine
[
'user'
][
'api_key'
];
...
...
@@ -354,7 +485,26 @@ if (isset($_GET['user-serialized'])) {
$redmine
=
&
$redmine_admin
;
}
switch
(
$_GET
[
'vacation-type'
])
{
case
'main'
:
$_GET
[
'vacation-type'
]
=
'ежегодный основной оплачиваемый отпуск'
;
$_GET
[
'of-vacation'
]
=
'ежегодного основного оплачиваемого отпуска'
;
break
;
case
'educational'
:
$_GET
[
'vacation-type'
]
=
'учебный отпуск'
;
$_GET
[
'of-vacation'
]
=
'учебного отпуска'
;
break
;
case
'free'
:
$_GET
[
'vacation-type'
]
=
'отпуск без сохранения заработной платы'
;
$_GET
[
'of-vacation'
]
=
'отпуска без сохранения заработной платы'
;
break
;
case
'parental'
:
$_GET
[
'vacation-type'
]
=
'отпуск по уходу за ребёнком до достижения им возраста трёх лет'
;
$_GET
[
'of-vacation'
]
=
'отпуска по уходу за ребёнком до достижения им возраста трёх лет'
;
break
;
}
$_GET_orig
=
$_GET
;
$custom_fields
=
NULL
;
...
...
@@ -362,10 +512,11 @@ $custom_fields_keys = array();
$files
=
split
(
','
,
$_GET
[
'file'
]);
$replacement_is_already_done
=
false
;
$pdfs
=
array
();
foreach
(
$files
as
$file
)
{
$split_appointments
=
false
;
// $replacement_is_already_done = false;
$file_eff
=
$file
;
switch
(
$file
)
{
case
'request/domain-name'
:
...
...
@@ -373,22 +524,6 @@ foreach ($files as $file) {
$memo_subject
=
'Запрос на регистрацию доменного имени'
;
$file_eff
=
$file
;
//.' '.$_GET['target-type'];
$_GET
[
'domain-name'
]
=
$_GET
[
'domain-name'
]
.
'.mephi.ru'
;
switch
(
$_GET
[
'target-type'
])
{
case
'ipaddr'
:
$_GET
[
'target-type'
]
=
'IP-адресом'
;
$_GET
[
'target-id'
]
=
$_GET
[
'ipaddr'
];
break
;
case
'container-name'
:
$_GET
[
'target-type'
]
=
'контейнером'
;
$_GET
[
'target-id'
]
=
'«'
.
$_GET
[
'container-name'
]
.
'»'
;
break
;
case
'issue-id'
:
$_GET
[
'target-type'
]
=
'ранее предоставленным хостингом по заявке'
;
$_GET
[
'target-id'
]
=
'#'
.
$_GET
[
'issue-id'
];
break
;
}
break
;
case
'request/vpn'
:
$project_id
=
84
;
...
...
@@ -429,27 +564,9 @@ foreach ($files as $file) {
break
;
case
'request/vacation'
:
$project_id
=
118
;
// $project_id = 1;
// $project_id = 1;
$memo_subject
=
'Заявление на отпуск'
;
switch
(
$_GET
[
'vacation-type'
])
{
case
'main'
:
$_GET
[
'vacation-type'
]
=
'ежегодный основной оплачиваемый отпуск'
;
$_GET
[
'of-vacation'
]
=
'ежегодного основного оплачиваемого отпуска'
;
break
;
case
'educational'
:
$_GET
[
'vacation-type'
]
=
'учебный отпуск'
;
$_GET
[
'of-vacation'
]
=
'учебного отпуска'
;
break
;
case
'free'
:
$_GET
[
'vacation-type'
]
=
'отпуск без сохранения заработной платы'
;
$_GET
[
'of-vacation'
]
=
'отпуска без сохранения заработной платы'
;
break
;
case
'parental'
:
$_GET
[
'vacation-type'
]
=
'отпуск по уходу за ребёнком до достижения им возраста трёх лет'
;
$_GET
[
'of-vacation'
]
=
'отпуска по уходу за ребёнком до достижения им возраста трёх лет'
;
break
;
}
$time_from
=
strtotime
(
$_GET
[
'days-from'
]);
$time_to
=
strtotime
(
$_GET
[
'days-to'
]);
...
...
@@ -460,13 +577,18 @@ foreach ($files as $file) {
$_GET
[
'days-count'
]
=
(
$days_diff
+
1
);
$split_appointments
=
true
;
break
;
case
'request/temporary-acting'
:
// print_r($_GET); die();
if
(
!
isset
(
$_GET
[
'user-e_id'
]))
continue
2
;
if
(
substr
(
$_GET
[
'of-user-fullname'
],
0
,
2
)
==
'\_'
)
$_GET
[
'of-user-fullname'
]
=
'\\\\'
.
"
\n
"
.
$_GET
[
'of-user-fullname'
];
$_GET
[
'of-user-fullname'
]
=
'\\\\'
.
"
\n
"
.
$_GET
[
'of-user-fullname'
];
$split_appointments
=
true
;
break
;
case
'request/voip-transfer-equipment'
:
$project_id
=
1
;
//18;
...
...
@@ -481,214 +603,451 @@ foreach ($files as $file) {
$project_id
=
12871
;
$memo_subject
=
'Заявка на предоставление PHP хостинга'
;
break
;
case
'request/itsupport'
:
$project_id
=
121
;
$memo_subject
=
'Заявка в службу технической поддержки'
;
$custom_fields_keys
=
array
(
14
=>
'contact-phonenumber'
,
13
=>
'contact-place'
,
4
=>
'subdivision'
);
break
;
case
'request/lanmodern'
:
$project_id
=
31
;
$memo_subject
=
'Заявка на модернизацию ЛВС'
;
break
;
case
'request/custom'
:
$project_id
=
redmine_proj_identifier2id
(
$_GET
[
'credentials'
]);
$memo_subject
=
'Служебная записка'
;
$me
[
'id'
]
=
$user_redmine
[
'user'
][
'id'
];
$replacement_is_already_done
=
true
;
break
;
default
:
die
(
'unknown memo-type'
);
}
if
(
!
is_null
(
$me
))
$redmine_admin
->
api
(
'membership'
)
->
create
(
$project_id
,
array
(
'user_id'
=>
$me
[
'id'
],
'role_ids'
=>
array
(
ROLE_CUSTOMER
)));
switch
(
$file
)
{
case
'request/voip3'
:
case
'request/cps'
:
case
'request/php'
:
if
(
empty
(
$_GET
[
'subdiv-code'
]))
{
if
(
!
empty
(
$_SERVER
[
'HTTP_REFERER'
]))
{
header
(
'Location: '
.
$_SERVER
[
'HTTP_REFERER'
]
.
'?errmsg='
.
urlencode
(
'Не указан код подразделения'
));
exit
(
0
);
}
else
die
(
'"subdiv-code" is not set'
);
if
(
!
is_null
(
$me
))
{
// $membership = $redmine_admin->api('user')->show($me['id'], array('include' => array('memberships',)));
$current_membership
=
$redmine_admin
->
api
(
'membership'
)
->
all
(
$project_id
);
//History of issue: If we have one user with role id:20, we can't create a custumer role.
//We must update roles for this user, for update we must know inner structure of memberships
//for debug
// print_r ($current_membership['memberships']);
// echo "ME:".$me['id']."\n";
foreach
(
$current_membership
[
'memberships'
]
as
$global_key
=>
$member
){
// echo "MEMBER KEY: $global_key\n";
// print_r ($member); die();
// echo $member['user']['id']."\n";
if
(
$member
[
'user'
][
'id'
]
==
$me
[
'id'
]){
$cur_roles
=
array
();
$membership_id
=
$current_membership
[
'memberships'
][
$global_key
][
'id'
];
foreach
(
$current_membership
[
'memberships'
][
$global_key
][
'roles'
]
as
$role
)
{
$cur_roles
[]
=
$role
[
'id'
];
}
//print_r($current_membership['memberships'][$global_key]);print_r($cur_roles);die();
$result
=
$redmine_admin
->
api
(
'membership'
)
->
update
(
$membership_id
,
array
(
'role_ids'
=>
array_merge
(
$cur_roles
,
array
(
ROLE_CUSTOMER
))));
// echo "RESULT $result \n @ $membership_id \n"; die();
}
$subdivs
=
json_decode
(
file_get_contents
(
'https://cps.mephi.ru/?cmd=getsubdivinfo&s_code='
.
$_GET
[
'subdiv-code'
]));
$subdiv
=
$subdivs
->
result
->
s0
;
$_GET
[
'subdiv-name'
]
=
$subdiv
->
name
;
break
;
case
'request/video'
:
if
(
empty
(
$_GET
[
'subdiv-code'
]))
{
if
(
!
empty
(
$_SERVER
[
'HTTP_REFERER'
]))
{
header
(
'Location: '
.
$_SERVER
[
'HTTP_REFERER'
]
.
'?errmsg='
.
urlencode
(
'Не указан код подразделения'
));
exit
(
0
);
}
else
die
(
'"subdiv-code" is not set'
);
else
{
$result
=
$redmine_admin
->
api
(
'membership'
)
->
create
(
$project_id
,
array
(
'user_id'
=>
$me
[
'id'
],
'role_ids'
=>
array
(
ROLE_CUSTOMER
)));
}
$subdivs
=
json_decode
(
file_get_contents
(
'https://cps.mephi.ru/?cmd=getsubdivinfo&s_code='
.
$_GET
[
'subdiv-code'
]));
$subdiv
=
$subdivs
->
result
->
s0
;
$_GET
[
'subdiv-name'
]
=
$subdiv
->
name
;
break
;
}
//TODO: PUT ALL ROLES
// echo $result;
// die();
}
foreach
(
$custom_fields_keys
as
$id
=>
$key
)
$custom_fields
[]
=
array
(
'id'
=>
$id
,
'value'
=>
empty
(
$_GET
[
$key
])
?
'0'
:
$_GET
[
$key
]);
// error_log(print_r($_GET_orig, 1));
$signer_appointment_count
=
1
;
$user_appointment_count
=
1
;
foreach
(
$_GET_orig
as
$k
=>
$v
)
{
if
(
$split_appointments
)
{
if
(
$split_appointments
&&
(
strstr
(
$k
,
"signer-"
)
||
strstr
(
$k
,
"user-"
))
&&
(
strstr
(
$k
,
"appointment"
)
||
strstr
(
$k
,
"subdiv"
)))
{
error_log
(
$k
.
' => '
.
print_r
(
$v
,
1
));
if
(
is_array
(
$v
))
{
$_GET_array
[
$k
]
=
$v
;
}
else
{
$_GET_array
[
$k
]
=
split
(
','
,
$v
);
}
if
(
strstr
(
$k
,
"signer-"
))
{
$signer_appointment_count
=
count
(
$_GET_array
[
$k
]);
}
else
if
(
strstr
(
$k
,
"user-"
))
{
$user_appointment_count
=
count
(
$_GET_array
[
$k
]);
}
continue
;
}
}
if
(
is_array
(
$v
))
{
$v
=
join
(
', '
,
$v
);
}
$_GET_array
[
$k
]
=
array
(
$v
,
$v
,
$v
,
$v
,
$v
,
$v
,
$v
,
$v
,
$v
,
$v
,
$v
,
$v
,
$v
,
$v
,
$v
,
$v
,
$v
);
}
$tempdir
=
tempdir
();
if
(
$split_appointments
)
{
$_GET_array_new
=
array
();
$i
=
0
;
while
(
$i
<
$signer_appointment_count
)
{
$j
=
0
;
while
(
$j
<
$user_appointment_count
)
{
$appointment_i
=
$i
+
$j
*
$signer_appointment_count
;
foreach
(
$_GET_array
as
$k
=>
$v
)
{
if
(
strstr
(
$k
,
"appointment"
)
||
strstr
(
$k
,
"subdiv"
))
{
if
(
strstr
(
$k
,
"signer-"
))
{
$_GET_array_new
[
$k
][
$appointment_i
]
=
$v
[
$i
];
}
else
if
(
strstr
(
$k
,
"user-"
))
{
$_GET_array_new
[
$k
][
$appointment_i
]
=
$v
[
$j
];
}
}
else
{
$_GET_array_new
[
$k
]
=
$v
;
}
}
$j
++
;
}
$i
++
;
}
$_GET_array
=
$_GET_array_new
;
}
if
(
$tempdir
===
FALSE
)
die
(
'Cannot create temporary directory'
);
$appointment_count
=
$signer_appointment_count
*
$user_appointment_count
;
$appointment_i
=
0
;
do
{
foreach
(
$_GET_array
as
$k
=>
$v
)
{
$_GET
[
$k
]
=
$v
[
$appointment_i
];
}
exec
(
'cp -a /var/www/ut.mephi.ru/ut-tex/mephimemo "'
.
$tempdir
.
'/"'
);
chdir
(
$tempdir
.
'/mephimemo'
);
file_put_contents
(
"request.get"
,
print_r
(
$_GET
,
true
));
switch
(
$file
)
{
case
'request/voip3'
:
case
'request/cps'
:
case
'request/php'
:
if
(
empty
(
$_GET
[
'subdiv-code'
]))
{
if
(
!
empty
(
$_SERVER
[
'HTTP_REFERER'
]))
{
header
(
'Location: '
.
$_SERVER
[
'HTTP_REFERER'
]
.
'?errmsg='
.
urlencode
(
'Не указан код подразделения'
));
exit
(
0
);
}
else
die
(
'"subdiv-code" is not set'
);
}
$subdivs
=
json_decode
(
file_get_contents
(
'https://cps.mephi.ru/?cmd=getsubdivinfo&s_code='
.
$_GET
[
'subdiv-code'
]));
$subdiv
=
$subdivs
->
result
->
s0
;
$_GET
[
'subdiv-name'
]
=
$subdiv
->
name
;
break
;
case
'request/video'
:
if
(
empty
(
$_GET
[
'subdiv-code'
]))
{
if
(
!
empty
(
$_SERVER
[
'HTTP_REFERER'
]))
{
header
(
'Location: '
.
$_SERVER
[
'HTTP_REFERER'
]
.
'?errmsg='
.
urlencode
(
'Не указан код подразделения'
));
exit
(
0
);
}
else
die
(
'"subdiv-code" is not set'
);
}
$subdivs
=
json_decode
(
file_get_contents
(
'https://cps.mephi.ru/?cmd=getsubdivinfo&s_code='
.
$_GET
[
'subdiv-code'
]));
$subdiv
=
$subdivs
->
result
->
s0
;
$_GET
[
'subdiv-name'
]
=
$subdiv
->
name
;
break
;
case
'request/domain-name'
:
$_GET
[
'domain-name'
]
=
$_GET
[
'domain-name'
]
.
'.mephi.ru'
;
if
(
!
$replacement_is_already_done
)
{
foreach
(
$_GET
as
$key
=>
&
$value
)
$value
=
str_replace
(
array
(
'\\'
,
'_'
,
'#'
),
array
(
'{\textbackslash}'
,
'\_'
,
'\\#'
),
$value
);
switch
(
$_GET
[
'target-type'
])
{
case
'ipaddr'
:
$_GET
[
'target-type'
]
=
'IP-адресом'
;
$_GET
[
'target-id'
]
=
$_GET
[
'ipaddr'
];
break
;
case
'container-name'
:
$_GET
[
'target-type'
]
=
'контейнером'
;
$_GET
[
'target-id'
]
=
'«'
.
$_GET
[
'container-name'
]
.
'»'
;
break
;
case
'issue-id'
:
$_GET
[
'target-type'
]
=
'ранее предоставленным хостингом по заявке'
;
$_GET
[
'target-id'
]
=
'#'
.
$_GET
[
'issue-id'
];
break
;
}
$replacement_is_already_done
=
true
;
}
break
;
file_put_contents
(
"request.get.fixed"
,
print_r
(
$_GET
,
true
));
}
#ob_start();
#print_r($_GET);
#$_GET_print_r = ob_get_clean();
$text
=
''
;
foreach
(
$custom_fields_keys
as
$id
=>
$key
)
$custom_fields
[]
=
array
(
'id'
=>
$id
,
'value'
=>
empty
(
$_GET
[
$key
])
?
'0'
:
$_GET
[
$key
]);
/*
if (empty($_GET['date-end']))
$_GET['date-end'] = (date('Y')+1).'-12-31';
*/
$tempdir
=
tempdir
();
$body_template
=
file_get_contents
(
'template/'
.
$file_eff
.
'.tex'
);
$body
=
body_parse
(
$body_template
);
if
(
$tempdir
===
FALSE
)
die
(
'Cannot create temporary directory'
);
switch
(
$file
)
{
case
'request/vacation'
:
$header
=
'\mmheaderstatement{Начальнику отдела кадров НИЯУ МИФИ}{}'
;
$footer
=
''
;
break
;
case
'request/temporary-acting'
:
$header
=
'\mmheadermemo{\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_}{\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_}'
;
$footer
=
'
\mmfooter{'
.
$_GET
[
'signer-appointment'
]
.
'}{'
.
$_GET
{
'signer-name'
}
.
'}{}{}
\\
\mmfooter{'
.
$_GET
[
'user-appointment'
]
.
'}{'
.
$_GET
{
'user-name'
}
.
'}{}{Согласен:}
'
;
break
;
case
'request/voip-transfer-equipment'
:
$header
=
'\mmfullheader{'
.
$_GET
[
'subdiv-name'
]
.
'}{Начальнику управления информатизации}{Романову Н.Н.}'
;
break
;
case
'request/video'
;