Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
d422c659
Commit
d422c659
authored
6 years ago
by
juanf
Browse files
Options
Downloads
Patches
Plain Diff
SSDM-7346 : Order loads fixed when status = NOT_ORDERED
parent
9e887f74
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/StandardProfile.js
+300
-291
300 additions, 291 deletions
...s/1/as/webapps/eln-lims/html/js/config/StandardProfile.js
with
300 additions
and
291 deletions
openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/StandardProfile.js
+
300
−
291
View file @
d422c659
...
...
@@ -372,173 +372,278 @@ $.extend(StandardProfile.prototype, DefaultProfile.prototype, {
}
else
if
(
sampleTypeCode
===
"
ORDER
"
)
{
var
isExisting
=
mainController
.
currentView
.
_sampleFormModel
.
mode
===
FormMode
.
VIEW
;
var
isFromState
=
false
;
if
(
isExisting
)
{
//
// Data Structures to Help the reports functionality
//
var
order
=
mainController
.
currentView
.
_sampleFormModel
.
sample
;
if
(
order
.
properties
[
"
ORDER_STATE
"
])
{
isFromState
=
true
;
order
=
JSON
.
parse
(
decodeURIComponent
(
escape
(
window
.
atob
(
order
.
properties
[
"
ORDER_STATE
"
]))));
}
var
requests
=
order
.
parents
;
var
providerByPermId
=
{};
var
productsByProviderPermId
=
{};
var
quantityByProductPermId
=
{};
var
absoluteTotalByCurrency
=
{};
//
// Fills data structures
//
for
(
var
rIdx
=
0
;
rIdx
<
requests
.
length
;
rIdx
++
)
{
var
request
=
requests
[
rIdx
];
var
requestProductsAnnotations
=
FormUtil
.
getAnnotationsFromSample
(
request
);
var
requestProducts
=
request
.
parents
;
for
(
var
pIdx
=
0
;
pIdx
<
requestProducts
.
length
;
pIdx
++
)
{
var
requestProduct
=
requestProducts
[
pIdx
];
var
requestProductAnnotations
=
requestProductsAnnotations
[
requestProduct
.
permId
];
if
(
requestProduct
.
parents
.
length
===
0
)
{
Util
.
showUserError
(
"
Product
"
+
requestProduct
.
code
+
"
does not have a provider, FIX IT!.
"
);
return
;
}
var
provider
=
requestProduct
.
parents
[
0
];
var
providerProducts
=
productsByProviderPermId
[
provider
.
permId
];
if
(
!
providerProducts
)
{
providerProducts
=
[];
productsByProviderPermId
[
provider
.
permId
]
=
providerProducts
;
providerByPermId
[
provider
.
permId
]
=
provider
;
}
var
quantity
=
quantityByProductPermId
[
requestProduct
.
permId
];
if
(
!
quantity
)
{
quantity
=
0
;
}
quantity
+=
parseInt
(
requestProductAnnotations
[
"
QUANTITY_OF_ITEMS
"
]);
if
(
!
quantity
)
{
Util
.
showUserError
(
"
Product
"
+
requestProduct
.
code
+
"
from request
"
+
request
.
code
+
"
does not have a quantity, FIX IT!.
"
);
return
;
}
var
currencyCode
=
requestProduct
.
properties
[
"
CURRENCY
"
];
if
(
!
currencyCode
)
{
currencyCode
=
"
N/A
"
;
}
var
absoluteTotalForCurrency
=
absoluteTotalByCurrency
[
currencyCode
];
if
(
!
absoluteTotalForCurrency
)
{
absoluteTotalForCurrency
=
0
;
}
if
(
requestProduct
.
properties
[
"
PRICE_PER_UNIT
"
])
{
absoluteTotalForCurrency
+=
parseFloat
(
requestProduct
.
properties
[
"
PRICE_PER_UNIT
"
])
*
quantity
;
if
(
isExisting
)
{
var
showOrderSummary
=
function
(
order
)
{
var
requests
=
order
.
parents
;
var
providerByPermId
=
{};
var
productsByProviderPermId
=
{};
var
quantityByProductPermId
=
{};
var
absoluteTotalByCurrency
=
{};
//
// Fills data structures
//
for
(
var
rIdx
=
0
;
rIdx
<
requests
.
length
;
rIdx
++
)
{
var
request
=
requests
[
rIdx
];
var
requestProductsAnnotations
=
FormUtil
.
getAnnotationsFromSample
(
request
);
var
requestProducts
=
request
.
parents
;
for
(
var
pIdx
=
0
;
pIdx
<
requestProducts
.
length
;
pIdx
++
)
{
var
requestProduct
=
requestProducts
[
pIdx
];
var
requestProductAnnotations
=
requestProductsAnnotations
[
requestProduct
.
permId
];
if
(
requestProduct
.
parents
.
length
===
0
)
{
Util
.
showUserError
(
"
Product
"
+
requestProduct
.
code
+
"
does not have a provider, FIX IT!.
"
);
return
;
}
var
provider
=
requestProduct
.
parents
[
0
];
var
providerProducts
=
productsByProviderPermId
[
provider
.
permId
];
if
(
!
providerProducts
)
{
providerProducts
=
[];
productsByProviderPermId
[
provider
.
permId
]
=
providerProducts
;
providerByPermId
[
provider
.
permId
]
=
provider
;
}
var
quantity
=
quantityByProductPermId
[
requestProduct
.
permId
];
if
(
!
quantity
)
{
quantity
=
0
;
}
quantity
+=
parseInt
(
requestProductAnnotations
[
"
QUANTITY_OF_ITEMS
"
]);
if
(
!
quantity
)
{
Util
.
showUserError
(
"
Product
"
+
requestProduct
.
code
+
"
from request
"
+
request
.
code
+
"
does not have a quantity, FIX IT!.
"
);
return
;
}
var
currencyCode
=
requestProduct
.
properties
[
"
CURRENCY
"
];
if
(
!
currencyCode
)
{
currencyCode
=
"
N/A
"
;
}
var
absoluteTotalForCurrency
=
absoluteTotalByCurrency
[
currencyCode
];
if
(
!
absoluteTotalForCurrency
)
{
absoluteTotalForCurrency
=
0
;
}
if
(
requestProduct
.
properties
[
"
PRICE_PER_UNIT
"
])
{
absoluteTotalForCurrency
+=
parseFloat
(
requestProduct
.
properties
[
"
PRICE_PER_UNIT
"
])
*
quantity
;
}
absoluteTotalByCurrency
[
currencyCode
]
=
absoluteTotalForCurrency
;
quantityByProductPermId
[
requestProduct
.
permId
]
=
quantity
;
providerProducts
.
push
(
requestProduct
);
}
absoluteTotalByCurrency
[
currencyCode
]
=
absoluteTotalForCurrency
;
quantityByProductPermId
[
requestProduct
.
permId
]
=
quantity
;
providerProducts
.
push
(
requestProduct
);
}
}
//
// Button that prints an order report
//
var
printOrder
=
FormUtil
.
getButtonWithIcon
(
"
glyphicon-print
"
,
function
()
{
//Create an order page for each provider
var
orderPages
=
[];
for
(
var
providerPermId
in
productsByProviderPermId
)
{
var
provider
=
providerByPermId
[
providerPermId
];
var
preferredSupplierLanguage
=
provider
.
properties
[
"
COMPANY_LANGUAGE
"
];
var
languageLabels
=
profile
.
orderLanguage
[
preferredSupplierLanguage
];
if
(
!
languageLabels
)
{
languageLabels
=
profile
.
orderLanguage
[
"
ENGLISH
"
];
}
var
providerProducts
=
productsByProviderPermId
[
providerPermId
];
var
registrationDate
=
null
;
if
(
order
.
registrationDetails
&&
order
.
registrationDetails
.
modificationDate
)
{
registrationDate
=
order
.
registrationDetails
.
modificationDate
;
}
else
if
(
mainController
.
currentView
.
_sampleFormModel
.
sample
.
registrationDetails
&&
mainController
.
currentView
.
_sampleFormModel
.
sample
.
registrationDetails
.
modificationDate
)
{
registrationDate
=
mainController
.
currentView
.
_sampleFormModel
.
sample
.
registrationDetails
.
modificationDate
;
}
var
page
=
languageLabels
[
"
ORDER_FORM
"
];
page
+=
"
\n
"
;
page
+=
"
\n
"
;
page
+=
languageLabels
[
"
ORDER_INFORMATION
"
];
page
+=
"
\n
"
;
page
+=
"
-
"
+
languageLabels
[
"
ORDER_DATE
"
]
+
"
:
"
+
Util
.
getFormatedDate
(
new
Date
(
registrationDate
));
page
+=
"
\n
"
;
page
+=
"
-
"
+
languageLabels
[
"
ORDER_STATUS
"
]
+
"
:
"
+
order
.
properties
[
"
ORDER_STATUS
"
];
page
+=
"
\n
"
;
page
+=
"
-
"
+
languageLabels
[
"
ORDER_CODE
"
]
+
"
:
"
+
order
.
code
;
page
+=
"
\n
"
;
page
+=
"
\n
"
;
page
+=
"
\n
"
;
page
+=
languageLabels
[
"
COSTUMER_INFORMATION
"
];
page
+=
"
\n
"
;
if
(
order
.
properties
[
"
SHIP_TO
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
SHIP_TO
"
]
+
"
:
"
+
order
.
properties
[
"
SHIP_TO
"
];
page
+=
"
\n
"
;
//
// Button that prints an order report
//
var
printOrder
=
FormUtil
.
getButtonWithIcon
(
"
glyphicon-print
"
,
function
()
{
//Create an order page for each provider
var
orderPages
=
[];
for
(
var
providerPermId
in
productsByProviderPermId
)
{
var
provider
=
providerByPermId
[
providerPermId
];
var
preferredSupplierLanguage
=
provider
.
properties
[
"
COMPANY_LANGUAGE
"
];
var
languageLabels
=
profile
.
orderLanguage
[
preferredSupplierLanguage
];
if
(
!
languageLabels
)
{
languageLabels
=
profile
.
orderLanguage
[
"
ENGLISH
"
];
}
if
(
order
.
properties
[
"
BILL_TO
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
BILL_TO
"
]
+
"
:
"
+
order
.
properties
[
"
BILL_TO
"
];
page
+=
"
\n
"
;
var
providerProducts
=
productsByProviderPermId
[
providerPermId
];
var
registrationDate
=
null
;
if
(
order
.
registrationDetails
&&
order
.
registrationDetails
.
modificationDate
)
{
registrationDate
=
order
.
registrationDetails
.
modificationDate
;
}
else
if
(
mainController
.
currentView
.
_sampleFormModel
.
sample
.
registrationDetails
&&
mainController
.
currentView
.
_sampleFormModel
.
sample
.
registrationDetails
.
modificationDate
)
{
registrationDate
=
mainController
.
currentView
.
_sampleFormModel
.
sample
.
registrationDetails
.
modificationDate
;
}
if
(
order
.
properties
[
"
SHIP_ADDRESS
"
])
{
page
+
=
"
-
"
+
languageLabels
[
"
SHIP_ADDRESS
"
]
+
"
:
"
+
order
.
properties
[
"
SHIP_ADDRESS
"
];
var
page
=
languageLabels
[
"
ORDER_FORM
"
];
page
+=
"
\n
"
;
}
if
(
order
.
properties
[
"
CONTACT_PHONE
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
PHONE
"
]
+
"
:
"
+
order
.
properties
[
"
CONTACT_PHONE
"
];
page
+=
"
\n
"
;
}
if
(
order
.
properties
[
"
CONTACT_FAX
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
FAX
"
]
+
"
:
"
+
order
.
properties
[
"
CONTACT_FAX
"
];
page
+=
languageLabels
[
"
ORDER_INFORMATION
"
];
page
+=
"
\n
"
;
}
page
+=
"
\n
"
;
page
+=
"
\n
"
;
page
+=
languageLabels
[
"
SUPPLIER_INFORMATION
"
];
page
+=
"
\n
"
;
if
(
provider
.
properties
[
"
NAME
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
SUPPLIER
"
]
+
"
:
"
+
provider
.
properties
[
"
NAME
"
];
page
+=
"
-
"
+
languageLabels
[
"
ORDER_DATE
"
]
+
"
:
"
+
Util
.
getFormatedDate
(
new
Date
(
registrationDate
));
page
+=
"
\n
"
;
}
if
(
provider
.
properties
[
"
COMPANY_ADDRESS_LINE_1
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
SUPPLIER_ADDRESS_LINE_1
"
]
+
"
:
"
+
provider
.
properties
[
"
COMPANY_ADDRESS_LINE_1
"
]
page
+=
"
-
"
+
languageLabels
[
"
ORDER_STATUS
"
]
+
"
:
"
+
order
.
properties
[
"
ORDER_STATUS
"
];
page
+=
"
\n
"
;
}
if
(
provider
.
properties
[
"
COMPANY_ADDRESS_LINE_2
"
])
{
page
+=
"
"
+
languageLabels
[
"
SUPPLIER_ADDRESS_LINE_2
"
]
+
"
"
+
provider
.
properties
[
"
COMPANY_ADDRESS_LINE_2
"
]
page
+=
"
-
"
+
languageLabels
[
"
ORDER_CODE
"
]
+
"
:
"
+
order
.
code
;
page
+=
"
\n
"
;
}
if
(
provider
.
properties
[
"
COMPANY_PHONE
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
SUPPLIER_PHONE
"
]
+
"
:
"
+
provider
.
properties
[
"
COMPANY_PHONE
"
];
page
+=
"
\n
"
;
}
if
(
provider
.
properties
[
"
COMPANY_FAX
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
SUPPLIER_FAX
"
]
+
"
:
"
+
provider
.
properties
[
"
COMPANY_FAX
"
];
page
+=
"
\n
"
;
}
if
(
provider
.
properties
[
"
COMPANY_EMAIL
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
SUPPLIER_EMAIL
"
]
+
"
:
"
+
provider
.
properties
[
"
COMPANY_EMAIL
"
];
page
+=
languageLabels
[
"
COSTUMER_INFORMATION
"
];
page
+=
"
\n
"
;
}
if
(
provider
.
properties
[
"
CUSTOMER_NUMBER
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
CUSTOMER_NUMBER
"
]
+
"
:
"
+
provider
.
properties
[
"
CUSTOMER_NUMBER
"
];
if
(
order
.
properties
[
"
SHIP_TO
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
SHIP_TO
"
]
+
"
:
"
+
order
.
properties
[
"
SHIP_TO
"
];
page
+=
"
\n
"
;
}
if
(
order
.
properties
[
"
BILL_TO
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
BILL_TO
"
]
+
"
:
"
+
order
.
properties
[
"
BILL_TO
"
];
page
+=
"
\n
"
;
}
if
(
order
.
properties
[
"
SHIP_ADDRESS
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
SHIP_ADDRESS
"
]
+
"
:
"
+
order
.
properties
[
"
SHIP_ADDRESS
"
];
page
+=
"
\n
"
;
}
if
(
order
.
properties
[
"
CONTACT_PHONE
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
PHONE
"
]
+
"
:
"
+
order
.
properties
[
"
CONTACT_PHONE
"
];
page
+=
"
\n
"
;
}
if
(
order
.
properties
[
"
CONTACT_FAX
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
FAX
"
]
+
"
:
"
+
order
.
properties
[
"
CONTACT_FAX
"
];
page
+=
"
\n
"
;
}
page
+=
"
\n
"
;
}
page
+=
"
\n
"
;
page
+=
"
\n
"
;
page
+=
languageLabels
[
"
REQUESTED_PRODUCTS_LABEL
"
];
page
+=
"
\n
"
;
page
+=
languageLabels
[
"
PRODUCTS_COLUMN_NAMES_LABEL
"
];
page
+=
"
\n
"
;
var
providerTotalByCurrency
=
{};
page
+=
"
\n
"
;
page
+=
languageLabels
[
"
SUPPLIER_INFORMATION
"
];
page
+=
"
\n
"
;
if
(
provider
.
properties
[
"
NAME
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
SUPPLIER
"
]
+
"
:
"
+
provider
.
properties
[
"
NAME
"
];
page
+=
"
\n
"
;
}
if
(
provider
.
properties
[
"
COMPANY_ADDRESS_LINE_1
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
SUPPLIER_ADDRESS_LINE_1
"
]
+
"
:
"
+
provider
.
properties
[
"
COMPANY_ADDRESS_LINE_1
"
]
page
+=
"
\n
"
;
}
if
(
provider
.
properties
[
"
COMPANY_ADDRESS_LINE_2
"
])
{
page
+=
"
"
+
languageLabels
[
"
SUPPLIER_ADDRESS_LINE_2
"
]
+
"
"
+
provider
.
properties
[
"
COMPANY_ADDRESS_LINE_2
"
]
page
+=
"
\n
"
;
}
if
(
provider
.
properties
[
"
COMPANY_PHONE
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
SUPPLIER_PHONE
"
]
+
"
:
"
+
provider
.
properties
[
"
COMPANY_PHONE
"
];
page
+=
"
\n
"
;
}
if
(
provider
.
properties
[
"
COMPANY_FAX
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
SUPPLIER_FAX
"
]
+
"
:
"
+
provider
.
properties
[
"
COMPANY_FAX
"
];
page
+=
"
\n
"
;
}
if
(
provider
.
properties
[
"
COMPANY_EMAIL
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
SUPPLIER_EMAIL
"
]
+
"
:
"
+
provider
.
properties
[
"
COMPANY_EMAIL
"
];
page
+=
"
\n
"
;
}
if
(
provider
.
properties
[
"
CUSTOMER_NUMBER
"
])
{
page
+=
"
-
"
+
languageLabels
[
"
CUSTOMER_NUMBER
"
]
+
"
:
"
+
provider
.
properties
[
"
CUSTOMER_NUMBER
"
];
page
+=
"
\n
"
;
}
page
+=
"
\n
"
;
page
+=
"
\n
"
;
page
+=
languageLabels
[
"
REQUESTED_PRODUCTS_LABEL
"
];
page
+=
"
\n
"
;
page
+=
languageLabels
[
"
PRODUCTS_COLUMN_NAMES_LABEL
"
];
page
+=
"
\n
"
;
var
providerTotalByCurrency
=
{};
for
(
var
pIdx
=
0
;
pIdx
<
providerProducts
.
length
;
pIdx
++
)
{
var
product
=
providerProducts
[
pIdx
];
var
quantity
=
quantityByProductPermId
[
product
.
permId
];
var
unitPriceAsString
=
product
.
properties
[
"
PRICE_PER_UNIT
"
];
var
unitPrice
=
"
N/A
"
;
if
(
unitPriceAsString
)
{
unitPrice
=
parseFloat
(
unitPriceAsString
);
}
var
currencyCode
=
product
.
properties
[
"
CURRENCY
"
];
if
(
!
currencyCode
)
{
currencyCode
=
"
N/A
"
;
}
page
+=
quantity
+
"
\t\t
"
+
product
.
properties
[
"
NAME
"
]
+
"
\t\t
"
+
product
.
properties
[
"
CATALOG_NUM
"
]
+
"
\t\t
"
+
unitPrice
+
"
"
+
currencyCode
;
page
+=
"
\n
"
;
if
(
unitPriceAsString
)
{
var
totalForCurrency
=
providerTotalByCurrency
[
product
.
properties
[
"
CURRENCY
"
]];
if
(
!
totalForCurrency
)
{
totalForCurrency
=
0
;
}
totalForCurrency
+=
unitPrice
*
quantity
;
providerTotalByCurrency
[
product
.
properties
[
"
CURRENCY
"
]]
=
totalForCurrency
;
}
else
{
providerTotalByCurrency
[
product
.
properties
[
"
CURRENCY
"
]]
=
"
N/A
"
;
}
}
page
+=
"
\n
"
;
page
+=
"
\n
"
;
page
+=
"
\n
"
;
var
showTotals
=
false
;
for
(
var
currency
in
providerTotalByCurrency
)
{
if
(
providerTotalByCurrency
[
currency
]
>
0
)
{
showTotals
=
true
;
}
}
if
(
showTotals
)
{
page
+=
languageLabels
[
"
PRICE_TOTALS_LABEL
"
]
+
"
:
"
;
page
+=
"
\n
"
;
for
(
var
currency
in
providerTotalByCurrency
)
{
page
+=
providerTotalByCurrency
[
currency
]
+
"
"
+
currency
;
page
+=
"
\n
"
;
}
page
+=
"
\n
"
;
page
+=
"
\n
"
;
page
+=
"
\n
"
;
}
page
+=
languageLabels
[
"
ADDITIONAL_INFO_LABEL
"
];
page
+=
"
\n
"
;
var
additionalInfo
=
order
.
properties
[
"
ADDITIONAL_INFORMATION
"
];
if
(
!
additionalInfo
)
{
additionalInfo
=
"
N/A
"
;
}
page
+=
additionalInfo
;
orderPages
.
push
(
page
);
}
//Print Pages
for
(
var
pageIdx
=
0
;
pageIdx
<
orderPages
.
length
;
pageIdx
++
)
{
Util
.
downloadTextFile
(
orderPages
[
pageIdx
],
"
order_
"
+
sample
.
code
+
"
_p
"
+
pageIdx
+
"
.txt
"
);
}
},
"
Print Order
"
);
//
// Order Summary Grid
//
var
columns
=
[
{
label
:
'
Catalog Num
'
,
property
:
'
catalogNum
'
,
isExportable
:
true
,
sortable
:
true
,
render
:
function
(
data
)
{
return
FormUtil
.
getFormLink
(
data
.
catalogNum
,
"
Sample
"
,
data
.
permId
);
}
},{
label
:
'
Supplier
'
,
property
:
'
supplier
'
,
isExportable
:
true
,
sortable
:
true
},
{
label
:
'
Name
'
,
property
:
'
name
'
,
isExportable
:
true
,
sortable
:
true
},
{
label
:
'
Quantity
'
,
property
:
'
quantity
'
,
isExportable
:
true
,
sortable
:
true
,
},
{
label
:
'
Unit Price
'
,
property
:
'
unitPrice
'
,
isExportable
:
true
,
sortable
:
true
},
{
label
:
'
Total Product Cost
'
,
property
:
'
totalProductCost
'
,
isExportable
:
true
,
sortable
:
true
},
{
label
:
'
Currency
'
,
property
:
'
currency
'
,
isExportable
:
true
,
sortable
:
true
}];
var
getDataRows
=
function
(
callback
)
{
var
rows
=
[];
for
(
var
providerPermId
in
productsByProviderPermId
)
{
var
provider
=
providerByPermId
[
providerPermId
];
var
providerProducts
=
productsByProviderPermId
[
providerPermId
];
for
(
var
pIdx
=
0
;
pIdx
<
providerProducts
.
length
;
pIdx
++
)
{
var
product
=
providerProducts
[
pIdx
];
var
quantity
=
quantityByProductPermId
[
product
.
permId
];
...
...
@@ -547,157 +652,61 @@ $.extend(StandardProfile.prototype, DefaultProfile.prototype, {
if
(
unitPriceAsString
)
{
unitPrice
=
parseFloat
(
unitPriceAsString
);
}
var
rowData
=
{};
rowData
.
permId
=
product
.
permId
;
rowData
.
supplier
=
provider
.
properties
[
"
NAME
"
];
rowData
.
name
=
product
.
properties
[
"
NAME
"
];
rowData
.
catalogNum
=
product
.
properties
[
"
CATALOG_NUM
"
];
rowData
.
quantity
=
quantity
;
rowData
.
unitPrice
=
unitPrice
;
if
(
unitPrice
!==
"
N/A
"
)
{
rowData
.
totalProductCost
=
rowData
.
quantity
*
rowData
.
unitPrice
;
}
else
{
rowData
.
totalProductCost
=
"
N/A
"
;
}
var
currencyCode
=
product
.
properties
[
"
CURRENCY
"
];
if
(
!
currencyCode
)
{
currencyCode
=
"
N/A
"
;
}
page
+=
quantity
+
"
\t\t
"
+
product
.
properties
[
"
NAME
"
]
+
"
\t\t
"
+
product
.
properties
[
"
CATALOG_NUM
"
]
+
"
\t\t
"
+
unitPrice
+
"
"
+
currencyCode
;
page
+=
"
\n
"
;
if
(
unitPriceAsString
)
{
var
totalForCurrency
=
providerTotalByCurrency
[
product
.
properties
[
"
CURRENCY
"
]];
if
(
!
totalForCurrency
)
{
totalForCurrency
=
0
;
}
totalForCurrency
+=
unitPrice
*
quantity
;
providerTotalByCurrency
[
product
.
properties
[
"
CURRENCY
"
]]
=
totalForCurrency
;
}
else
{
providerTotalByCurrency
[
product
.
properties
[
"
CURRENCY
"
]]
=
"
N/A
"
;
}
rowData
.
currency
=
currencyCode
;
rows
.
push
(
rowData
);
}
page
+=
"
\n
"
;
page
+=
"
\n
"
;
page
+=
"
\n
"
;
var
showTotals
=
false
;
for
(
var
currency
in
providerTotalByCurrency
)
{
if
(
providerTotalByCurrency
[
currency
]
>
0
)
{
showTotals
=
true
;
}
}
if
(
showTotals
)
{
page
+=
languageLabels
[
"
PRICE_TOTALS_LABEL
"
]
+
"
:
"
;
page
+=
"
\n
"
;
for
(
var
currency
in
providerTotalByCurrency
)
{
page
+=
providerTotalByCurrency
[
currency
]
+
"
"
+
currency
;
page
+=
"
\n
"
;
}
page
+=
"
\n
"
;
page
+=
"
\n
"
;
page
+=
"
\n
"
;
}
page
+=
languageLabels
[
"
ADDITIONAL_INFO_LABEL
"
];
page
+=
"
\n
"
;
var
additionalInfo
=
order
.
properties
[
"
ADDITIONAL_INFORMATION
"
];
if
(
!
additionalInfo
)
{
additionalInfo
=
"
N/A
"
;
}
page
+=
additionalInfo
;
orderPages
.
push
(
page
);
}
}
callback
(
rows
);
};
//Print Pages
for
(
var
pageIdx
=
0
;
pageIdx
<
orderPages
.
length
;
pageIdx
++
)
{
Util
.
downloadTextFile
(
orderPages
[
pageIdx
],
"
order_
"
+
sample
.
code
+
"
_p
"
+
pageIdx
+
"
.txt
"
);
var
orderSummaryContainer
=
$
(
"
<div>
"
);
var
repTitle
=
"
Order Summary
"
;
if
(
isFromState
)
{
repTitle
+=
"
(as saved when ordered)
"
}
},
"
Print Order
"
);
//
// Order Summary Grid
//
var
columns
=
[
{
label
:
'
Catalog Num
'
,
property
:
'
catalogNum
'
,
isExportable
:
true
,
sortable
:
true
,
render
:
function
(
data
)
{
return
FormUtil
.
getFormLink
(
data
.
catalogNum
,
"
Sample
"
,
data
.
permId
);
}
},{
label
:
'
Supplier
'
,
property
:
'
supplier
'
,
isExportable
:
true
,
sortable
:
true
},
{
label
:
'
Name
'
,
property
:
'
name
'
,
isExportable
:
true
,
sortable
:
true
},
{
label
:
'
Quantity
'
,
property
:
'
quantity
'
,
isExportable
:
true
,
sortable
:
true
,
},
{
label
:
'
Unit Price
'
,
property
:
'
unitPrice
'
,
isExportable
:
true
,
sortable
:
true
},
{
label
:
'
Total Product Cost
'
,
property
:
'
totalProductCost
'
,
isExportable
:
true
,
sortable
:
true
},
{
label
:
'
Currency
'
,
property
:
'
currency
'
,
isExportable
:
true
,
sortable
:
true
}];
var
getDataRows
=
function
(
callback
)
{
var
rows
=
[];
for
(
var
providerPermId
in
productsByProviderPermId
)
{
var
provider
=
providerByPermId
[
providerPermId
];
var
providerProducts
=
productsByProviderPermId
[
providerPermId
];
for
(
var
pIdx
=
0
;
pIdx
<
providerProducts
.
length
;
pIdx
++
)
{
var
product
=
providerProducts
[
pIdx
];
var
quantity
=
quantityByProductPermId
[
product
.
permId
];
var
unitPriceAsString
=
product
.
properties
[
"
PRICE_PER_UNIT
"
];
var
unitPrice
=
"
N/A
"
;
if
(
unitPriceAsString
)
{
unitPrice
=
parseFloat
(
unitPriceAsString
);
}
var
rowData
=
{};
rowData
.
permId
=
product
.
permId
;
rowData
.
supplier
=
provider
.
properties
[
"
NAME
"
];
rowData
.
name
=
product
.
properties
[
"
NAME
"
];
rowData
.
catalogNum
=
product
.
properties
[
"
CATALOG_NUM
"
];
rowData
.
quantity
=
quantity
;
rowData
.
unitPrice
=
unitPrice
;
if
(
unitPrice
!==
"
N/A
"
)
{
rowData
.
totalProductCost
=
rowData
.
quantity
*
rowData
.
unitPrice
;
}
else
{
rowData
.
totalProductCost
=
"
N/A
"
;
}
var
currencyCode
=
product
.
properties
[
"
CURRENCY
"
];
if
(
!
currencyCode
)
{
currencyCode
=
"
N/A
"
;
}
rowData
.
currency
=
currencyCode
;
rows
.
push
(
rowData
);
}
var
orderSummary
=
new
DataGridController
(
repTitle
,
columns
,
[],
null
,
getDataRows
,
null
,
false
,
"
ORDER_SUMMARY
"
);
orderSummary
.
init
(
orderSummaryContainer
);
var
totalsByCurrencyContainer
=
$
(
"
<div>
"
).
append
(
$
(
"
<br>
"
)).
append
(
$
(
"
<legend>
"
).
append
(
"
Total:
"
));
for
(
var
currency
in
absoluteTotalByCurrency
)
{
totalsByCurrencyContainer
.
append
(
absoluteTotalByCurrency
[
currency
]
+
"
"
+
currency
).
append
(
$
(
"
<br>
"
));
}
callback
(
rows
);
};
var
orderSummaryContainer
=
$
(
"
<div>
"
);
var
repTitle
=
"
Order Summary
"
;
if
(
isFromState
)
{
repTitle
+=
"
(as saved when ordered)
"
$
(
"
#
"
+
containerId
).
append
(
orderSummaryContainer
).
append
(
totalsByCurrencyContainer
).
append
(
$
(
"
<br>
"
)).
append
(
printOrder
);
}
var
orderSummary
=
new
DataGridController
(
repTitle
,
columns
,
[],
null
,
getDataRows
,
null
,
false
,
"
ORDER_SUMMARY
"
);
orderSummary
.
init
(
orderSummaryContainer
);
var
totalsByCurrencyContainer
=
$
(
"
<div>
"
).
append
(
$
(
"
<br>
"
)).
append
(
$
(
"
<legend>
"
).
append
(
"
Total:
"
));
for
(
var
currency
in
absoluteTotalByCurrency
)
{
totalsByCurrencyContainer
.
append
(
absoluteTotalByCurrency
[
currency
]
+
"
"
+
currency
).
append
(
$
(
"
<br>
"
));
//
// Data Structures to Help the reports functionality
//
var
orderSample
=
mainController
.
currentView
.
_sampleFormModel
.
sample
;
if
(
orderSample
.
properties
[
"
ORDER_STATE
"
])
{
isFromState
=
true
;
var
order
=
JSON
.
parse
(
decodeURIComponent
(
escape
(
window
.
atob
(
orderSample
.
properties
[
"
ORDER_STATE
"
]))));
showOrderSummary
(
order
);
}
else
{
var
searchSamples
=
{
entityKind
:
"
SAMPLE
"
,
logicalOperator
:
"
OR
"
,
rules
:
{
"
UUIDv4
"
:
{
type
:
"
Attribute
"
,
name
:
"
PERM_ID
"
,
value
:
orderSample
.
permId
}
}
};
mainController
.
serverFacade
.
searchForSamplesAdvanced
(
searchSamples
,
{
only
:
true
,
withProperties
:
true
,
withAncestors
:
true
,
withAncestorsProperties
:
true
},
function
(
result
)
{
var
order
=
mainController
.
serverFacade
.
getV3SamplesAsV1
(
result
.
objects
)[
0
];
showOrderSummary
(
order
);
});
}
$
(
"
#
"
+
containerId
).
append
(
orderSummaryContainer
).
append
(
totalsByCurrencyContainer
).
append
(
$
(
"
<br>
"
)).
append
(
printOrder
);
}
}
else
if
(
sampleTypeCode
===
"
REQUEST
"
)
{
var
isEnabled
=
mainController
.
currentView
.
_sampleFormModel
.
mode
!==
FormMode
.
VIEW
;
...
...
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