Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
justinfreeman (Agileware)
Core
Commits
6d4a64c8
Commit
6d4a64c8
authored
11 years ago
by
Kurund Jalmi
Browse files
Options
Downloads
Patches
Plain Diff
code cleanup and also added 'Save and Preview' option CRM-12965
parent
80bb6572
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CRM/Badge/BAO/Badge.php
+95
-4
95 additions, 4 deletions
CRM/Badge/BAO/Badge.php
CRM/Badge/Form/Layout.php
+51
-7
51 additions, 7 deletions
CRM/Badge/Form/Layout.php
CRM/Event/Form/Task/Badge.php
+8
-80
8 additions, 80 deletions
CRM/Event/Form/Task/Badge.php
with
154 additions
and
91 deletions
CRM/Badge/BAO/Badge.php
+
95
−
4
View file @
6d4a64c8
...
...
@@ -235,7 +235,7 @@ class CRM_Badge_BAO_Badge {
'stretchtext'
=>
0
,
);
$this
->
pdf
->
write1DBarcode
(
$data
[
'current_value'
],
'C128'
,
$xAlign
,
$y
+
$this
->
pdf
->
height
-
10
,
''
,
$this
->
pdf
->
write1DBarcode
(
$data
[
'current_value'
],
'C128'
,
$xAlign
,
$y
+
$this
->
pdf
->
height
-
10
,
'
65
'
,
12
,
0.4
,
$style
,
'B'
);
}
else
{
...
...
@@ -244,7 +244,7 @@ class CRM_Badge_BAO_Badge {
switch
(
$formattedRow
[
'barcode'
][
'alignment'
])
{
case
'L'
:
$xAlign
+=
-
8
;
$xAlign
+=
-
4
;
break
;
case
'R'
:
$xAlign
+=
63
;
...
...
@@ -263,8 +263,8 @@ class CRM_Badge_BAO_Badge {
'position'
=>
''
,
);
$this
->
pdf
->
write2DBarcode
(
$data
[
'current_value'
],
'QRCODE,
Q
'
,
$xAlign
,
$y
+
$this
->
pdf
->
height
-
2
3
,
3
0
,
3
0
,
$style
,
'B'
);
$this
->
pdf
->
write2DBarcode
(
$data
[
'current_value'
],
'QRCODE,
H
'
,
$xAlign
,
$y
+
$this
->
pdf
->
height
-
2
0
,
2
3
,
2
3
,
$style
,
'B'
);
}
}
}
...
...
@@ -298,5 +298,96 @@ class CRM_Badge_BAO_Badge {
}
$this
->
pdf
->
SetXY
(
$x
,
$y
);
}
/**
* function to build badges parameters before actually creating badges.
*
* @param array $params associated array of submitted values
* @params object $form form/controller object
*
* @return void
* @access public
* @static
*/
public
static
function
buildBadges
(
&
$params
,
&
$form
)
{
// get name badge layout info
$layoutInfo
=
CRM_Badge_BAO_Layout
::
buildLayout
(
$params
);
// spit / get actual field names from token
$returnProperties
=
array
();
if
(
!
empty
(
$layoutInfo
[
'data'
][
'token'
]))
{
foreach
(
$layoutInfo
[
'data'
][
'token'
]
as
$index
=>
$value
)
{
$element
=
''
;
if
(
$value
)
{
$token
=
CRM_Utils_Token
::
getTokens
(
$value
);
if
(
key
(
$token
)
==
'contact'
)
{
$element
=
$token
[
'contact'
][
0
];
}
elseif
(
key
(
$token
)
==
'event'
)
{
$element
=
$token
[
'event'
][
0
];
//FIX ME - we need to standardize event token names
if
(
!
strpos
(
$element
,
'event_'
))
{
$element
=
'event_'
.
$element
;
}
}
elseif
(
key
(
$token
)
==
'participant'
)
{
$element
=
$token
[
'participant'
][
0
];
}
// build returnproperties for query
$returnProperties
[
$element
]
=
1
;
}
// add actual field name to row element
$layoutInfo
[
'data'
][
'rowElements'
][
$index
]
=
$element
;
}
}
// add additional required fields for query execution
$additionalFields
=
array
(
'participant_register_date'
,
'participant_id'
,
'event_id'
,
'contact_id'
);
foreach
(
$additionalFields
as
$field
)
{
$returnProperties
[
$field
]
=
1
;
}
if
(
$form
->
_single
)
{
$queryParams
=
NULL
;
}
else
{
$queryParams
=
$form
->
get
(
'queryParams'
);
}
$query
=
new
CRM_Contact_BAO_Query
(
$queryParams
,
$returnProperties
,
NULL
,
FALSE
,
FALSE
,
CRM_Contact_BAO_Query
::
MODE_EVENT
);
list
(
$select
,
$from
,
$where
,
$having
)
=
$query
->
query
();
if
(
empty
(
$where
))
{
$where
=
"WHERE
{
$form
->
_componentClause
}
"
;
}
else
{
$where
.
=
" AND
{
$form
->
_componentClause
}
"
;
}
$sortOrder
=
NULL
;
if
(
$form
->
get
(
CRM_Utils_Sort
::
SORT_ORDER
))
{
$sortOrder
=
$form
->
get
(
CRM_Utils_Sort
::
SORT_ORDER
);
if
(
!
empty
(
$sortOrder
))
{
$sortOrder
=
" ORDER BY
$sortOrder
"
;
}
}
$queryString
=
"
$select
$from
$where
$having
$sortOrder
"
;
$dao
=
CRM_Core_DAO
::
executeQuery
(
$queryString
);
$rows
=
array
();
while
(
$dao
->
fetch
())
{
$rows
[
$dao
->
participant_id
]
=
array
();
foreach
(
$returnProperties
as
$key
=>
$dontCare
)
{
$rows
[
$dao
->
participant_id
][
$key
]
=
isset
(
$dao
->
$key
)
?
$dao
->
$key
:
NULL
;
}
}
$eventBadgeClass
=
new
CRM_Badge_BAO_Badge
();
$eventBadgeClass
->
createLabels
(
$rows
,
$layoutInfo
);
}
}
This diff is collapsed.
Click to expand it.
CRM/Badge/Form/Layout.php
+
51
−
7
View file @
6d4a64c8
...
...
@@ -46,9 +46,19 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
* @access public
*/
public
function
buildQuickForm
()
{
parent
::
buildQuickForm
();
if
(
$this
->
_action
&
CRM_Core_Action
::
DELETE
)
{
$this
->
addButtons
(
array
(
array
(
'type'
=>
'next'
,
'name'
=>
ts
(
'Delete'
),
'isDefault'
=>
TRUE
,
),
array
(
'type'
=>
'cancel'
,
'name'
=>
ts
(
'Cancel'
),
),
)
);
return
;
}
...
...
@@ -110,6 +120,23 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
$this
->
add
(
'checkbox'
,
'is_reserved'
,
ts
(
'Reserved?'
));
$this
->
addFormRule
(
array
(
'CRM_Badge_Form_Layout'
,
'formRule'
));
$this
->
addButtons
(
array
(
array
(
'type'
=>
'next'
,
'name'
=>
ts
(
'Save'
),
'isDefault'
=>
TRUE
,
),
array
(
'type'
=>
'refresh'
,
'name'
=>
ts
(
'Save and Preview'
),
),
array
(
'type'
=>
'cancel'
,
'name'
=>
ts
(
'Cancel'
),
),
)
);
}
/**
...
...
@@ -181,7 +208,7 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
return
;
}
$params
=
$data
=
$this
->
controller
->
exportValues
(
$this
->
_name
);
$params
=
$data
=
$this
->
exportValues
();
unset
(
$data
[
'qfKey'
]);
$params
[
'data'
]
=
json_encode
(
$data
);
...
...
@@ -191,10 +218,27 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
}
// store the submitted values in an array
CRM_Badge_BAO_Layout
::
create
(
$params
);
$badgeInfo
=
CRM_Badge_BAO_Layout
::
create
(
$params
);
if
(
isset
(
$params
[
'_qf_Layout_refresh'
]))
{
$params
[
'badge_id'
]
=
$badgeInfo
->
id
;
self
::
buildPreview
(
$params
);
}
else
{
CRM_Core_Session
::
setStatus
(
ts
(
"The badge layout '%1' has been saved."
,
array
(
1
=>
$params
[
'title'
])
),
ts
(
'Saved'
),
'success'
);
}
}
public
function
buildPreview
(
&
$params
)
{
// get a max participant id
$participantID
=
CRM_Core_DAO
::
singleValueQuery
(
'select max(id) from civicrm_participant'
);
$this
->
_single
=
TRUE
;
$this
->
_participantIds
=
array
(
$participantID
);
$this
->
_componentClause
=
" civicrm_participant.id =
$participantID
"
;
CRM_Core_Session
::
setStatus
(
ts
(
"The badge layout '%1' has been saved."
,
array
(
1
=>
$params
[
'title'
])
),
ts
(
'Saved'
),
'success'
);
CRM_Badge_BAO_Badge
::
buildBadges
(
$params
,
$this
);
}
}
This diff is collapsed.
Click to expand it.
CRM/Event/Form/Task/Badge.php
+
8
−
80
View file @
6d4a64c8
...
...
@@ -47,6 +47,11 @@ class CRM_Event_Form_Task_Badge extends CRM_Event_Form_Task {
*/
public
$_single
=
FALSE
;
/**
* component clause
*/
public
$_componentClause
;
/**
* build all the data structures needed to build the form
*
...
...
@@ -54,7 +59,8 @@ class CRM_Event_Form_Task_Badge extends CRM_Event_Form_Task {
*
* @return void
* @access public
*/
function
preProcess
()
{
*/
function
preProcess
()
{
$this
->
_context
=
CRM_Utils_Request
::
retrieve
(
'context'
,
'String'
,
$this
);
if
(
$this
->
_context
==
'view'
)
{
$this
->
_single
=
TRUE
;
...
...
@@ -110,85 +116,7 @@ class CRM_Event_Form_Task_Badge extends CRM_Event_Form_Task {
*/
public
function
postProcess
()
{
$params
=
$this
->
controller
->
exportValues
(
$this
->
_name
);
// get name badge layout info
$layoutInfo
=
CRM_Badge_BAO_Layout
::
buildLayout
(
$params
);
// spit / get actual field names from token
$returnProperties
=
array
();
if
(
!
empty
(
$layoutInfo
[
'data'
][
'token'
]))
{
foreach
(
$layoutInfo
[
'data'
][
'token'
]
as
$index
=>
$value
)
{
$element
=
''
;
if
(
$value
)
{
$token
=
CRM_Utils_Token
::
getTokens
(
$value
);
if
(
key
(
$token
)
==
'contact'
)
{
$element
=
$token
[
'contact'
][
0
];
}
elseif
(
key
(
$token
)
==
'event'
)
{
$element
=
$token
[
'event'
][
0
];
//FIX ME - we need to standardize event token names
if
(
!
strpos
(
$element
,
'event_'
))
{
$element
=
'event_'
.
$element
;
}
}
elseif
(
key
(
$token
)
==
'participant'
)
{
$element
=
$token
[
'participant'
][
0
];
}
// build returnproperties for query
$returnProperties
[
$element
]
=
1
;
}
// add actual field name to row element
$layoutInfo
[
'data'
][
'rowElements'
][
$index
]
=
$element
;
}
}
// add additional required fields for query execution
$additionalFields
=
array
(
'participant_register_date'
,
'participant_id'
,
'event_id'
,
'contact_id'
);
foreach
(
$additionalFields
as
$field
)
{
$returnProperties
[
$field
]
=
1
;
}
if
(
$this
->
_single
)
{
$queryParams
=
NULL
;
}
else
{
$queryParams
=
$this
->
get
(
'queryParams'
);
}
$query
=
new
CRM_Contact_BAO_Query
(
$queryParams
,
$returnProperties
,
NULL
,
FALSE
,
FALSE
,
CRM_Contact_BAO_Query
::
MODE_EVENT
);
list
(
$select
,
$from
,
$where
,
$having
)
=
$query
->
query
();
if
(
empty
(
$where
))
{
$where
=
"WHERE
{
$this
->
_componentClause
}
"
;
}
else
{
$where
.
=
" AND
{
$this
->
_componentClause
}
"
;
}
$sortOrder
=
NULL
;
if
(
$this
->
get
(
CRM_Utils_Sort
::
SORT_ORDER
))
{
$sortOrder
=
$this
->
get
(
CRM_Utils_Sort
::
SORT_ORDER
);
if
(
!
empty
(
$sortOrder
))
{
$sortOrder
=
" ORDER BY
$sortOrder
"
;
}
}
$queryString
=
"
$select
$from
$where
$having
$sortOrder
"
;
$dao
=
CRM_Core_DAO
::
executeQuery
(
$queryString
);
$rows
=
array
();
while
(
$dao
->
fetch
())
{
$rows
[
$dao
->
participant_id
]
=
array
();
foreach
(
$returnProperties
as
$key
=>
$dontCare
)
{
$rows
[
$dao
->
participant_id
][
$key
]
=
isset
(
$dao
->
$key
)
?
$dao
->
$key
:
NULL
;
}
}
$eventBadgeClass
=
new
CRM_Badge_BAO_Badge
();
$eventBadgeClass
->
createLabels
(
$rows
,
$layoutInfo
);
CRM_Badge_BAO_Badge
::
buildBadges
(
$params
,
$this
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment