|
|
|
export const hideAttr = [
|
|
|
|
"geom",
|
|
|
|
"password",
|
|
|
|
"id",
|
|
|
|
"username",
|
|
|
|
"created_date",
|
|
|
|
"created_by",
|
|
|
|
"modified_date",
|
|
|
|
"modified_by",
|
|
|
|
"updated_by",
|
|
|
|
"updated_date",
|
|
|
|
"updated_at",
|
|
|
|
"session_login",
|
|
|
|
"company",
|
|
|
|
"buffer_radius",
|
|
|
|
"group_sales",
|
|
|
|
"OBJECTID",
|
|
|
|
"fcm_token",
|
|
|
|
"key",
|
|
|
|
"planning_id",
|
|
|
|
"subproyek_id",
|
|
|
|
"user_id",
|
|
|
|
"created_at",
|
|
|
|
"_type", // waspang
|
|
|
|
"satuan_id",
|
|
|
|
"m_planning_nama",
|
|
|
|
"m_planning_target",
|
|
|
|
"m_satuan_description",
|
|
|
|
"m_subproyek_akhir_proyek",
|
|
|
|
"m_subproyek_area_kerja",
|
|
|
|
"m_subproyek_biaya",
|
|
|
|
"m_subproyek_biaya_actual",
|
|
|
|
"m_subproyek_color_progress",
|
|
|
|
"m_subproyek_jumlah_pekerja",
|
|
|
|
"m_subproyek_ket_progress",
|
|
|
|
"m_subproyek_lokasi_kantor",
|
|
|
|
"m_subproyek_mulai_proyek",
|
|
|
|
"m_subproyek_nama",
|
|
|
|
"m_subproyek_persentase_progress_actual",
|
|
|
|
"m_subproyek_persentase_progress_plan",
|
|
|
|
"m_users_email",
|
|
|
|
"m_users_username",
|
|
|
|
"m_planning_address",
|
|
|
|
"m_planning_jumlah_titik",
|
|
|
|
"m_planning_target_planning",
|
|
|
|
"m_satuan_name",
|
|
|
|
"m_subproyek_pic",
|
|
|
|
"m_users_gender",
|
|
|
|
"m_users_name",
|
|
|
|
"m_users_phone_number",
|
|
|
|
];
|
|
|
|
|
|
|
|
export const salesAttrShow = [
|
|
|
|
"id",
|
|
|
|
"group_sales_name",
|
|
|
|
"name",
|
|
|
|
"phone_number",
|
|
|
|
"email",
|
|
|
|
"address"
|
|
|
|
];
|
|
|
|
|
|
|
|
export const dateColumns = [
|
|
|
|
"created_date",
|
|
|
|
"modified_date",
|
|
|
|
"birth_date",
|
|
|
|
"datesend", // last_waypoint_employee
|
|
|
|
"wptime", // last_waypoint_employee
|
|
|
|
"tanggal",
|
|
|
|
"mulai_tugas",
|
|
|
|
"akhir_tugas"
|
|
|
|
];
|
|
|
|
|
|
|
|
export const DATE_TIME_FORMAT = "DD-MM-YYYY";
|
|
|
|
|
|
|
|
export const COLUMN_DAILY_INFO_TABLE = [
|
|
|
|
{
|
|
|
|
dataField: 'id',
|
|
|
|
text: 'ID',
|
|
|
|
hidden: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
dataField: 'join.group_employee_name',
|
|
|
|
text: 'Group Employee'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
dataField: 'name',
|
|
|
|
text: 'Name'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
dataField: 'phone_number',
|
|
|
|
text: 'Phone Number'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
dataField: 'email',
|
|
|
|
text: 'Email'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
dataField: 'address',
|
|
|
|
text: 'Address'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
dataField: 'clock_in',
|
|
|
|
text: 'Clock In'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
dataField: 'clock_out',
|
|
|
|
text: 'Clock Out'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
export const formatLabel = (label) => {
|
|
|
|
let output = "";
|
|
|
|
|
|
|
|
if (label.includes("_")) {
|
|
|
|
let words = label.split("_");
|
|
|
|
for (let i=0; i < words.length; i++) {
|
|
|
|
words[i] = words[i].charAt(0).toUpperCase() + words[i].substr(1);
|
|
|
|
}
|
|
|
|
output = words.join(' ');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
output = label.charAt(0).toUpperCase() + label.slice(1);
|
|
|
|
}
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const QUERY_BUILDER_FIELD_SALES =
|
|
|
|
{
|
|
|
|
"properties->username": {
|
|
|
|
label: 'Username',
|
|
|
|
type: 'text',
|
|
|
|
valueSources: ['value'],
|
|
|
|
},
|
|
|
|
"properties->name": {
|
|
|
|
label: 'Name',
|
|
|
|
type: 'text',
|
|
|
|
valueSources: ['value'],
|
|
|
|
},
|
|
|
|
"properties->email": {
|
|
|
|
label: 'Email',
|
|
|
|
type: 'text',
|
|
|
|
valueSources: ['value'],
|
|
|
|
},
|
|
|
|
"properties->address": {
|
|
|
|
label: 'Address',
|
|
|
|
type: 'text',
|
|
|
|
valueSources: ['value'],
|
|
|
|
},
|
|
|
|
"properties->phone_number": {
|
|
|
|
label: 'Phone Number',
|
|
|
|
type: 'number',
|
|
|
|
valueSources: ['value'],
|
|
|
|
},
|
|
|
|
"properties->type_sales": {
|
|
|
|
label: 'Type Sales',
|
|
|
|
type: 'select',
|
|
|
|
valueSources: ['value'],
|
|
|
|
fieldSettings: {
|
|
|
|
listValues: [
|
|
|
|
{ value: 'B2B', title: 'B2B' },
|
|
|
|
{ value: 'B2C', title: 'B2C' },
|
|
|
|
],
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export const QUERY_BUILDER_FIELD_CUSTOMER =
|
|
|
|
{
|
|
|
|
"properties->name": {
|
|
|
|
label: 'Name',
|
|
|
|
type: 'text',
|
|
|
|
valueSources: ['value'],
|
|
|
|
},
|
|
|
|
"properties->buffer_radius": {
|
|
|
|
label: 'Buffer Radius',
|
|
|
|
type: 'number',
|
|
|
|
fieldSettings: {
|
|
|
|
min: 1,
|
|
|
|
},
|
|
|
|
valueSources: ['value'],
|
|
|
|
},
|
|
|
|
"properties->address": {
|
|
|
|
label: 'Address',
|
|
|
|
type: 'text',
|
|
|
|
valueSources: ['value'],
|
|
|
|
},
|
|
|
|
"properties->income": {
|
|
|
|
label: 'Income',
|
|
|
|
type: 'number',
|
|
|
|
valueSources: ['value'],
|
|
|
|
},
|
|
|
|
"properties->store_manager": {
|
|
|
|
label: 'Store Manager',
|
|
|
|
type: 'text',
|
|
|
|
valueSources: ['value'],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export const QUERY_BUILDER_FIELD_OFFICE =
|
|
|
|
{
|
|
|
|
"properties->company": {
|
|
|
|
label: 'Company',
|
|
|
|
type: 'text',
|
|
|
|
valueSources: ['value'],
|
|
|
|
},
|
|
|
|
"properties->name": {
|
|
|
|
label: 'Name',
|
|
|
|
type: 'text',
|
|
|
|
valueSources: ['value'],
|
|
|
|
},
|
|
|
|
"properties->employes": {
|
|
|
|
label: 'Employe',
|
|
|
|
type: 'text',
|
|
|
|
valueSources: ['value'],
|
|
|
|
},
|
|
|
|
"properties->address": {
|
|
|
|
label: 'Alamat',
|
|
|
|
type: 'text',
|
|
|
|
valueSources: ['value'],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const getChildrenTree = (data) =>
|
|
|
|
data.map((item, index) => {
|
|
|
|
if (item.subproyeks && item.subproyeks.length > 0) {
|
|
|
|
return {
|
|
|
|
"children": getChildrenTree(item.subproyeks),
|
|
|
|
"title": item.nama,
|
|
|
|
"key": Math.random(),
|
|
|
|
"id": item.id,
|
|
|
|
...item
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
"title": item.nama,
|
|
|
|
"key": Math.random(),
|
|
|
|
...item
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
export const formatRupiah = (angka, prefix) => {
|
|
|
|
var number_string = angka.replace(/[^,\d]/g, '').toString(),
|
|
|
|
split = number_string.split(','),
|
|
|
|
sisa = split[0].length % 3,
|
|
|
|
rupiah = split[0].substr(0, sisa),
|
|
|
|
ribuan = split[0].substr(sisa).match(/\d{3}/gi);
|
|
|
|
var separator = "";
|
|
|
|
if(ribuan){
|
|
|
|
separator = sisa ? '.' : '';
|
|
|
|
rupiah += separator + ribuan.join('.');
|
|
|
|
}
|
|
|
|
|
|
|
|
rupiah = split[1] != undefined ? rupiah + ',' + split[1] : rupiah;
|
|
|
|
return prefix == undefined ? rupiah : (rupiah ? 'Rp. ' + rupiah : '');
|
|
|
|
}
|
|
|
|
|
|
|
|
export const renderFormatRupiah = (text, prefix) => {
|
|
|
|
text = text.split('.')[0];
|
|
|
|
if (text) {
|
|
|
|
return formatRupiah(text, prefix)
|
|
|
|
} else {
|
|
|
|
return "-"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const formatNumber = (angka) => {
|
|
|
|
var number_string = angka.replace(/[^,\d]/g, '').toString(),
|
|
|
|
split = number_string.split(','),
|
|
|
|
sisa = split[0].length % 3,
|
|
|
|
rupiah = split[0].substr(0, sisa),
|
|
|
|
ribuan = split[0].substr(sisa).match(/\d{3}/gi);
|
|
|
|
var separator = "";
|
|
|
|
if(ribuan){
|
|
|
|
separator = sisa ? '.' : '';
|
|
|
|
rupiah += separator + ribuan.join('.');
|
|
|
|
}
|
|
|
|
|
|
|
|
rupiah = split[1] != undefined ? rupiah + ',' + split[1] : rupiah;
|
|
|
|
return rupiah
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const formatThousand = (x) => {
|
|
|
|
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Using it:
|
|
|
|
sortBy(data, {
|
|
|
|
prop: "date",
|
|
|
|
desc: true,
|
|
|
|
parser: function (item) {
|
|
|
|
return item.toUpperCase();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
*/
|
|
|
|
export const sortBy = (function () {
|
|
|
|
var toString = Object.prototype.toString,
|
|
|
|
parse = function (x) { return x; },
|
|
|
|
getItem = function (x) {
|
|
|
|
var isObject = x != null && typeof x === "object";
|
|
|
|
var isProp = isObject && this.prop in x;
|
|
|
|
return this.parser(isProp ? x[this.prop] : x);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sorts an array of elements.
|
|
|
|
*
|
|
|
|
* @param {Array} array: the collection to sort
|
|
|
|
* @param {Object} cfg: the configuration options
|
|
|
|
* @property {String} cfg.prop: property name (if it is an Array of objects)
|
|
|
|
* @property {Boolean} cfg.desc: determines whether the sort is descending
|
|
|
|
* @property {Function} cfg.parser: function to parse the items to expected type
|
|
|
|
* @return {Array}
|
|
|
|
*/
|
|
|
|
return function sortby (array, cfg) {
|
|
|
|
if (!(array instanceof Array && array.length)) return [];
|
|
|
|
if (toString.call(cfg) !== "[object Object]") cfg = {};
|
|
|
|
if (typeof cfg.parser !== "function") cfg.parser = parse;
|
|
|
|
cfg.desc = !!cfg.desc ? -1 : 1;
|
|
|
|
return array.sort(function (a, b) {
|
|
|
|
a = getItem.call(cfg, a);
|
|
|
|
b = getItem.call(cfg, b);
|
|
|
|
return cfg.desc * (a < b ? -1 : +(a > b));
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
}());
|
|
|
|
|
|
|
|
|
|
|
|
export const uniqueKeyValues = (arr, key) => {
|
|
|
|
return [... new Set(arr.map((obj) => {return obj[key]}))];
|
|
|
|
}
|
|
|
|
|
|
|
|
export const renderLabelStatus = (text) => {
|
|
|
|
let label = text;
|
|
|
|
if (text === 'fom' || text === 'fot' || text === 'po') {
|
|
|
|
label = text.toUpperCase();
|
|
|
|
}
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const formatRibuanDecimal = (n) => {
|
|
|
|
let parts=n.toString().split(".");
|
|
|
|
return "Rp. " + parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ".") + (parts[1] ? "," + parts[1] : "");
|
|
|
|
}
|
|
|
|
|
|
|
|
export const capitalizeFirstLetter = (string) => {
|
|
|
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
|
|
}
|