Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
third-party
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alexis AOUN
third-party
Commits
301b9756
Commit
301b9756
authored
Jul 03, 2021
by
François
Committed by
Alexis Aoun
Jul 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow Special FTOP to easy validate shift (and eslint auto fix)
parent
96403dcd
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
195 additions
and
101 deletions
+195
-101
models.py
members/models.py
+38
-0
members.js
members/static/js/members.js
+67
-57
views.py
members/views.py
+14
-1
orders_helper.js
orders/static/js/orders_helper.js
+71
-40
config.md
outils/config.md
+4
-1
all_common.js
outils/static/js/all_common.js
+1
-2
No files found.
members/models.py
View file @
301b9756
...
@@ -1176,6 +1176,44 @@ class CagetteServices(models.Model):
...
@@ -1176,6 +1176,44 @@ class CagetteServices(models.Model):
result
[
'service_found'
]
=
False
result
[
'service_found'
]
=
False
return
result
return
result
@staticmethod
def
easy_validate_shift_presence
(
coop_id
):
"""Add a presence point if the request is valid."""
res
=
{}
try
:
api
=
OdooAPI
()
# let verify coop_id is corresponding to a ftop subscriber
cond
=
[[
'id'
,
'='
,
coop_id
]]
fields
=
[
'shift_type'
]
coop
=
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
if
coop
:
if
coop
[
0
][
'shift_type'
]
==
'ftop'
:
evt_name
=
getattr
(
settings
,
'ENTRANCE_ADD_PT_EVENT_NAME'
,
'Validation service comité'
)
c
=
[[
'partner_id'
,
'='
,
coop_id
],
[
'name'
,
'='
,
evt_name
]]
f
=
[
'create_date'
]
last_point_mvts
=
api
.
search_read
(
'shift.counter.event'
,
c
,
f
,
order
=
"create_date DESC"
,
limit
=
1
)
ok_for_adding_pt
=
False
if
len
(
last_point_mvts
):
now
=
datetime
.
datetime
.
now
()
past
=
datetime
.
datetime
.
strptime
(
last_point_mvts
[
0
][
'create_date'
],
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
if
(
now
-
past
)
.
total_seconds
()
>=
3600
*
24
:
ok_for_adding_pt
=
True
else
:
ok_for_adding_pt
=
True
if
ok_for_adding_pt
is
True
:
res
[
'evt_id'
]
=
CagetteMember
(
coop_id
)
.
add_pts
(
'ftop'
,
1
,
evt_name
)
else
:
res
[
'error'
]
=
"One point has been added less then 24 hours ago"
else
:
res
[
'error'
]
=
"Unallowed coop"
else
:
res
[
'error'
]
=
"Invalid coop id"
except
Exception
as
e
:
coop_logger
.
error
(
"easy_validate_shift_presence :
%
s
%
s"
,
str
(
coop_id
),
str
(
e
))
return
res
class
CagetteUser
(
models
.
Model
):
class
CagetteUser
(
models
.
Model
):
@staticmethod
@staticmethod
...
...
members/static/js/members.js
View file @
301b9756
...
@@ -24,6 +24,8 @@ var current_displayed_member = null,
...
@@ -24,6 +24,8 @@ var current_displayed_member = null,
rattrapage_ou_volant
=
null
,
rattrapage_ou_volant
=
null
,
timeout_counter
=
null
;
timeout_counter
=
null
;
var
search_button
=
$
(
'.btn--primary.search'
);
var
search_button
=
$
(
'.btn--primary.search'
);
var
sm_search_member_button
=
$
(
'#sm_search_member_button'
),
sm_search_member_input
=
$
(
'#sm_search_member_input'
);
var
loading2
=
$
(
'.loading2'
);
var
loading2
=
$
(
'.loading2'
);
var
search_field
=
$
(
'input[name="search_string"]'
);
var
search_field
=
$
(
'input[name="search_string"]'
);
var
shift_title
=
$
(
'#current_shift_title'
);
var
shift_title
=
$
(
'#current_shift_title'
);
...
@@ -163,7 +165,7 @@ function canSearch() {
...
@@ -163,7 +165,7 @@ function canSearch() {
function
search_member
(
force_search
=
false
)
{
function
search_member
(
force_search
=
false
)
{
chars
=
[];
// to prevent false "as barcode-reader" input
chars
=
[];
// to prevent false "as barcode-reader" input
operator
=
null
operator
=
null
;
if
(
canSearch
()
||
force_search
)
{
if
(
canSearch
()
||
force_search
)
{
html_elts
.
member_slide
.
hide
();
html_elts
.
member_slide
.
hide
();
...
@@ -281,11 +283,15 @@ function fill_service_entry(s) {
...
@@ -281,11 +283,15 @@ function fill_service_entry(s) {
rattrapage_wanted
.
show
();
rattrapage_wanted
.
show
();
}
}
function
clean_se
rvice_entry
()
{
function
clean_se
arch_for_easy_validate_zone
()
{
$
(
'.search_member_results_area'
).
hide
();
$
(
'.search_member_results_area'
).
hide
();
$
(
'.search_member_results'
).
empty
();
$
(
'.search_member_results'
).
empty
();
$
(
'#sm_search_member_input'
).
val
(
''
);
sm_search_member_input
.
val
(
''
);
operator
=
null
operator
=
null
;
}
function
clean_service_entry
()
{
clean_search_for_easy_validate_zone
();
rattrapage_wanted
.
hide
();
rattrapage_wanted
.
hide
();
shift_title
.
text
(
''
);
shift_title
.
text
(
''
);
shift_members
.
html
(
''
);
shift_members
.
html
(
''
);
...
@@ -677,30 +683,30 @@ function ask_for_easy_shift_validation() {
...
@@ -677,30 +683,30 @@ function ask_for_easy_shift_validation() {
//alert("operator = " + JSON.stringify(operator))
//alert("operator = " + JSON.stringify(operator))
msg
=
"<p>Je suis bien "
+
operator
.
name
+
"<br/> et <br/>je valide mon service 'Comité' </p>"
;
msg
=
"<p>Je suis bien "
+
operator
.
name
+
"<br/> et <br/>je valide mon service 'Comité' </p>"
;
openModal
(
msg
,
function
()
{
openModal
(
msg
,
function
()
{
try
{
try
{
post_form
(
post_form
(
'/members/easy_validate_shift_presence'
,
'/members/easy_validate_shift_presence'
,
{
{
coop_id
:
operator
.
id
,
coop_id
:
operator
.
id
},
},
function
(
err
,
result
)
{
function
(
err
,
result
)
{
if
(
!
err
)
{
console
.
log
(
result
);
alert
(
"1 point volant vient d'être ajouté."
);
if
(
!
err
)
{
clean_search_for_easy_validate_zone
();
if
(
typeof
(
result
.
msg
)
!=
"undefined"
)
{
closeModal
();
alert
(
result
.
msg
);
}
else
{
}
else
if
(
result
.
action
===
null
)
{
if
(
typeof
(
err
.
responseJSON
)
!=
"undefined"
console
.
log
(
'ok'
)
&&
typeof
(
err
.
responseJSON
.
error
)
!=
"undefined"
)
{
}
alert
(
err
.
responseJSON
.
error
);
closeModal
();
}
else
{
}
else
{
console
.
log
(
err
);
console
.
log
(
err
)
}
}
}
);
}
catch
(
e
)
{
console
.
log
(
e
);
}
}
}
);
}
catch
(
e
)
{
console
.
log
(
e
);
}
},
'Confirmer'
);
},
'Confirmer'
);
}
}
// Display the members from the search result (copied from stock_movements)
// Display the members from the search result (copied from stock_movements)
...
@@ -723,13 +729,11 @@ function display_possible_members() {
...
@@ -723,13 +729,11 @@ function display_possible_members() {
+
'</button>'
;
+
'</button>'
;
$
(
'.search_member_results'
).
append
(
member_button
);
$
(
'.search_member_results'
).
append
(
member_button
);
// Set action on click on a member button
// Set action on click on a member button
$
(
'.btn_member'
).
on
(
'click'
,
function
()
{
$
(
'.btn_member'
).
on
(
'click'
,
function
()
{
for
(
member
of
members_search_results
)
{
for
(
member
of
members_search_results
)
{
if
(
member
.
id
==
$
(
this
).
attr
(
'member_id'
))
{
if
(
member
.
id
==
$
(
this
).
attr
(
'member_id'
))
{
operator
=
member
;
operator
=
member
;
// Enable validation button when operator is selected
// Enable validation button when operator is selected
ask_for_easy_shift_validation
();
ask_for_easy_shift_validation
();
break
;
break
;
...
@@ -784,37 +788,43 @@ $(document).ready(function() {
...
@@ -784,37 +788,43 @@ $(document).ready(function() {
});
});
$
(
'#sm_search_member_form'
).
submit
(
function
()
{
$
(
'#sm_search_member_form'
).
submit
(
function
()
{
let
search_str
=
$
(
'#sm_search_member_input'
).
val
();
if
(
is_time_to
(
'search_member'
,
1000
))
{
$
.
ajax
({
sm_search_member_button
.
empty
().
append
(
`<i class="fas fa-spinner fa-spin"></i>`
);
url
:
'/members/search/'
+
search_str
,
let
search_str
=
sm_search_member_input
.
val
();
dataType
:
'json'
,
success
:
function
(
data
)
{
$
.
ajax
({
members_search_results
=
[];
url
:
'/members/search/'
+
search_str
,
dataType
:
'json'
,
for
(
member
of
data
.
res
)
{
success
:
function
(
data
)
{
console
.
log
(
member
)
members_search_results
=
[];
if
(
member
.
shift_type
==
'ftop'
)
{
members_search_results
.
push
(
member
);
for
(
member
of
data
.
res
)
{
if
(
member
.
shift_type
==
'ftop'
)
{
members_search_results
.
push
(
member
);
}
}
}
display_possible_members
();
},
error
:
function
(
data
)
{
err
=
{
msg
:
"erreur serveur lors de la recherche de membres"
,
ctx
:
'easy_validate.search_members'
};
report_JS_error
(
err
,
'members'
);
$
.
notify
(
"Erreur lors de la recherche de membre, il faut ré-essayer plus tard..."
,
{
globalPosition
:
"top right"
,
className
:
"error"
});
},
complete
:
function
()
{
sm_search_member_button
.
empty
().
append
(
`Recherche`
);
}
}
});
}
});
display_possible_members
();
},
error
:
function
(
data
)
{
err
=
{
msg
:
"erreur serveur lors de la recherche de membres"
,
ctx
:
'easy_validate.search_members'
};
report_JS_error
(
err
,
'members'
);
$
.
notify
(
"Erreur lors de la recherche de membre, il faut ré-essayer plus tard..."
,
{
globalPosition
:
"top right"
,
className
:
"error"
});
}
});
})
});
});
Webcam
.
on
(
'live'
,
function
()
{
Webcam
.
on
(
'live'
,
function
()
{
...
...
members/views.py
View file @
301b9756
...
@@ -286,7 +286,20 @@ def record_service_presence(request):
...
@@ -286,7 +286,20 @@ def record_service_presence(request):
return
JsonResponse
({
'res'
:
res
})
return
JsonResponse
({
'res'
:
res
})
def
easy_validate_shift_presence
(
request
):
def
easy_validate_shift_presence
(
request
):
return
JsonResponse
({})
"""Add a presence point if the request is valid."""
res
=
{}
try
:
coop_id
=
int
(
request
.
POST
.
get
(
"coop_id"
,
"nan"
))
res
=
CagetteServices
.
easy_validate_shift_presence
(
coop_id
)
except
Exception
as
e
:
res
[
'error'
]
=
str
(
e
)
if
'error'
in
res
:
if
res
[
'error'
]
==
"One point has been added less then 24 hours ago"
:
# TODO : use translation (all project wide)
res
[
'error'
]
=
"Vous ne pouvez pas valider plus d'un service par 24h"
return
JsonResponse
(
res
,
status
=
500
)
else
:
return
JsonResponse
(
res
,
safe
=
False
)
def
record_absences
(
request
):
def
record_absences
(
request
):
return
JsonResponse
({
'res'
:
CagetteServices
.
record_absences
()})
return
JsonResponse
({
'res'
:
CagetteServices
.
record_absences
()})
...
...
orders/static/js/orders_helper.js
View file @
301b9756
...
@@ -119,6 +119,7 @@ function add_product() {
...
@@ -119,6 +119,7 @@ function add_product() {
contentType
:
"application/json; charset=utf-8"
,
contentType
:
"application/json; charset=utf-8"
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
let
res
=
data
.
products
[
0
];
let
res
=
data
.
products
[
0
];
if
(
typeof
res
.
id
!=
"undefined"
)
{
if
(
typeof
res
.
id
!=
"undefined"
)
{
res
.
suppliersinfo
=
[];
res
.
suppliersinfo
=
[];
res
.
default_code
=
' '
;
res
.
default_code
=
' '
;
...
@@ -153,21 +154,21 @@ function compute_products_coverage_qties() {
...
@@ -153,21 +154,21 @@ function compute_products_coverage_qties() {
]
of
Object
.
entries
(
products
))
{
]
of
Object
.
entries
(
products
))
{
if
(
'suppliersinfo'
in
product
&&
product
.
suppliersinfo
.
length
>
0
)
{
if
(
'suppliersinfo'
in
product
&&
product
.
suppliersinfo
.
length
>
0
)
{
let
purchase_qty_for_coverage
=
null
;
let
purchase_qty_for_coverage
=
null
;
// Durée couverture produit = (stock + qté entrante + qté commandée ) / conso quotidienne
// Durée couverture produit = (stock + qté entrante + qté commandée ) / conso quotidienne
const
stock
=
product
.
qty_available
;
const
stock
=
product
.
qty_available
;
const
incoming_qty
=
product
.
incoming_qty
;
const
incoming_qty
=
product
.
incoming_qty
;
const
daily_conso
=
product
.
daily_conso
;
const
daily_conso
=
product
.
daily_conso
;
purchase_qty_for_coverage
=
order_doc
.
coverage_days
*
daily_conso
-
stock
-
incoming_qty
;
purchase_qty_for_coverage
=
order_doc
.
coverage_days
*
daily_conso
-
stock
-
incoming_qty
;
purchase_qty_for_coverage
=
(
purchase_qty_for_coverage
<
0
)
?
0
:
purchase_qty_for_coverage
;
purchase_qty_for_coverage
=
(
purchase_qty_for_coverage
<
0
)
?
0
:
purchase_qty_for_coverage
;
// Reduce to nb of packages to purchase
// Reduce to nb of packages to purchase
purchase_package_qty_for_coverage
=
purchase_qty_for_coverage
/
product
.
suppliersinfo
[
0
].
package_qty
;
purchase_package_qty_for_coverage
=
purchase_qty_for_coverage
/
product
.
suppliersinfo
[
0
].
package_qty
;
// Round up to unit for all products
// Round up to unit for all products
purchase_package_qty_for_coverage
=
Math
.
ceil
(
purchase_package_qty_for_coverage
);
purchase_package_qty_for_coverage
=
Math
.
ceil
(
purchase_package_qty_for_coverage
);
// Set qty to purchase for first supplier only
// Set qty to purchase for first supplier only
products
[
key
].
suppliersinfo
[
0
].
qty
=
purchase_package_qty_for_coverage
;
products
[
key
].
suppliersinfo
[
0
].
qty
=
purchase_package_qty_for_coverage
;
}
}
...
@@ -190,7 +191,8 @@ function check_products_data() {
...
@@ -190,7 +191,8 @@ function check_products_data() {
}
}
);
);
clicked_order_pill
.
find
(
'.pill_order_name'
).
empty
().
append
(
`<i class="fas fa-spinner fa-spin"></i>`
);
clicked_order_pill
.
find
(
'.pill_order_name'
).
empty
()
.
append
(
`<i class="fas fa-spinner fa-spin"></i>`
);
$
.
ajax
({
$
.
ajax
({
type
:
'GET'
,
type
:
'GET'
,
...
@@ -207,12 +209,14 @@ function check_products_data() {
...
@@ -207,12 +209,14 @@ function check_products_data() {
// Override products data with new data (without suppliersinfo so we don't override qty)
// Override products data with new data (without suppliersinfo so we don't override qty)
const
updated_suppliersinfo
=
product
.
suppliersinfo
;
const
updated_suppliersinfo
=
product
.
suppliersinfo
;
delete
product
.
suppliersinfo
;
delete
product
.
suppliersinfo
;
products
[
p_index
]
=
{
...
products
[
p_index
],
...
product
};
products
[
p_index
]
=
{
...
products
[
p_index
],
...
product
};
// Update suppliers info
// Update suppliers info
for
(
let
psi_index
in
products
[
p_index
].
suppliersinfo
)
{
for
(
let
psi_index
in
products
[
p_index
].
suppliersinfo
)
{
const
updated_psi
=
updated_suppliersinfo
.
find
(
psi
=>
psi
.
supplier_id
==
products
[
p_index
].
suppliersinfo
[
psi_index
].
supplier_id
);
const
updated_psi
=
updated_suppliersinfo
.
find
(
psi
=>
psi
.
supplier_id
==
products
[
p_index
].
suppliersinfo
[
psi_index
].
supplier_id
);
if
(
updated_psi
!==
undefined
)
{
if
(
updated_psi
!==
undefined
)
{
products
[
p_index
].
suppliersinfo
[
psi_index
].
package_qty
=
updated_psi
.
package_qty
;
products
[
p_index
].
suppliersinfo
[
psi_index
].
package_qty
=
updated_psi
.
package_qty
;
products
[
p_index
].
suppliersinfo
[
psi_index
].
price
=
updated_psi
.
price
;
products
[
p_index
].
suppliersinfo
[
psi_index
].
price
=
updated_psi
.
price
;
...
@@ -278,6 +282,7 @@ function add_supplier() {
...
@@ -278,6 +282,7 @@ function add_supplier() {
selected_suppliers
.
push
(
supplier
);
selected_suppliers
.
push
(
supplier
);
let
url
=
"/orders/get_supplier_products"
;
let
url
=
"/orders/get_supplier_products"
;
url
+=
"?sids="
+
encodeURIComponent
(
supplier
.
id
);
url
+=
"?sids="
+
encodeURIComponent
(
supplier
.
id
);
// Fetch supplier products
// Fetch supplier products
...
@@ -485,6 +490,7 @@ function _compute_total_values_by_supplier() {
...
@@ -485,6 +490,7 @@ function _compute_total_values_by_supplier() {
let
supplier_index
=
selected_suppliers
.
findIndex
(
s
=>
s
.
id
==
supinfo
.
supplier_id
);
let
supplier_index
=
selected_suppliers
.
findIndex
(
s
=>
s
.
id
==
supinfo
.
supplier_id
);
let
product_supplier_value
=
(
'qty'
in
supinfo
)
?
supinfo
.
qty
*
supinfo
.
package_qty
*
supinfo
.
price
:
0
;
let
product_supplier_value
=
(
'qty'
in
supinfo
)
?
supinfo
.
qty
*
supinfo
.
package_qty
*
supinfo
.
price
:
0
;
selected_suppliers
[
supplier_index
].
total_value
+=
product_supplier_value
;
selected_suppliers
[
supplier_index
].
total_value
+=
product_supplier_value
;
}
}
}
}
...
@@ -589,7 +595,8 @@ function generate_inventory() {
...
@@ -589,7 +595,8 @@ function generate_inventory() {
modal_create_inventory
.
html
(),
modal_create_inventory
.
html
(),
()
=>
{
()
=>
{
if
(
is_time_to
(
'validate_generate_inventory'
))
{
if
(
is_time_to
(
'validate_generate_inventory'
))
{
$
(
'#do_inventory'
).
empty
().
append
(
`<i class="fas fa-spinner fa-spin"></i>`
);
$
(
'#do_inventory'
).
empty
()
.
append
(
`<i class="fas fa-spinner fa-spin"></i>`
);
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
"/inventory/generate_inventory_list"
,
url
:
"/inventory/generate_inventory_list"
,
...
@@ -599,10 +606,11 @@ function generate_inventory() {
...
@@ -599,10 +606,11 @@ function generate_inventory() {
data
:
JSON
.
stringify
(
data
),
data
:
JSON
.
stringify
(
data
),
success
:
()
=>
{
success
:
()
=>
{
unselect_all_rows
();
unselect_all_rows
();
// Give time for modal to fade
// Give time for modal to fade
setTimeout
(
function
()
{
setTimeout
(
function
()
{
$
(
'#do_inventory'
).
empty
().
append
(
`Faire un inventaire`
);
$
(
'#do_inventory'
).
empty
()
.
append
(
`Faire un inventaire`
);
$
(
'#do_inventory'
).
notify
(
$
(
'#do_inventory'
).
notify
(
"Inventaire créé !"
,
"Inventaire créé !"
,
{
{
...
@@ -613,15 +621,16 @@ function generate_inventory() {
...
@@ -613,15 +621,16 @@ function generate_inventory() {
},
200
);
},
200
);
},
},
error
:
function
(
data
)
{
error
:
function
(
data
)
{
$
(
'#do_inventory'
).
empty
().
append
(
`Faire un inventaire`
);
$
(
'#do_inventory'
).
empty
()
.
append
(
`Faire un inventaire`
);
let
msg
=
"erreur serveur lors de la création de l'inventaire"
.
let
msg
=
"erreur serveur lors de la création de l'inventaire"
.
err
=
{
msg
:
msg
,
ctx
:
'generate_inventory'
};
err
=
{
msg
:
msg
,
ctx
:
'generate_inventory'
};
if
(
typeof
data
.
responseJSON
!=
'undefined'
&&
typeof
data
.
responseJSON
.
error
!=
'undefined'
)
{
if
(
typeof
data
.
responseJSON
!=
'undefined'
&&
typeof
data
.
responseJSON
.
error
!=
'undefined'
)
{
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
;
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
;
}
}
report_JS_error
(
err
,
'orders'
);
report_JS_error
(
err
,
'orders'
);
alert
(
"Erreur lors de la création de l'inventaire. Réessayez plus tard."
);
alert
(
"Erreur lors de la création de l'inventaire. Réessayez plus tard."
);
}
}
});
});
...
@@ -643,12 +652,12 @@ function order_pill_on_click() {
...
@@ -643,12 +652,12 @@ function order_pill_on_click() {
clicked_order_pill
=
$
(
this
);
clicked_order_pill
=
$
(
this
);
let
order_name_container
=
clicked_order_pill
.
find
(
'.pill_order_name'
);
let
order_name_container
=
clicked_order_pill
.
find
(
'.pill_order_name'
);
let
doc_id
=
$
(
order_name_container
).
text
();
let
doc_id
=
$
(
order_name_container
).
text
();
dbc
.
get
(
doc_id
).
then
((
doc
)
=>
{
dbc
.
get
(
doc_id
).
then
((
doc
)
=>
{
if
(
doc
.
last_update
.
fingerprint
!==
fingerprint
)
{
if
(
doc
.
last_update
.
fingerprint
!==
fingerprint
)
{
time_diff
=
dates_diff
(
new
Date
(
doc
.
last_update
.
timestamp
),
new
Date
());
time_diff
=
dates_diff
(
new
Date
(
doc
.
last_update
.
timestamp
),
new
Date
());
diff_str
=
``
;
diff_str
=
``
;
if
(
time_diff
.
days
!==
0
)
{
if
(
time_diff
.
days
!==
0
)
{
diff_str
+=
`
${
time_diff
.
days
}
jour(s), `
;
diff_str
+=
`
${
time_diff
.
days
}
jour(s), `
;
}
}
...
@@ -659,11 +668,11 @@ function order_pill_on_click() {
...
@@ -659,11 +668,11 @@ function order_pill_on_click() {
diff_str
+=
`
${
time_diff
.
min
}
min, `
;
diff_str
+=
`
${
time_diff
.
min
}
min, `
;
}
}
diff_str
+=
`
${
time_diff
.
sec
}
s`
;
diff_str
+=
`
${
time_diff
.
sec
}
s`
;
let
modal_order_access
=
$
(
'#templates #modal_order_access'
);
let
modal_order_access
=
$
(
'#templates #modal_order_access'
);
modal_order_access
.
find
(
".order_last_update"
).
text
(
diff_str
);
modal_order_access
.
find
(
".order_last_update"
).
text
(
diff_str
);
openModal
(
openModal
(
modal_order_access
.
html
(),
modal_order_access
.
html
(),
()
=>
{
()
=>
{
...
@@ -777,17 +786,19 @@ function create_orders() {
...
@@ -777,17 +786,19 @@ function create_orders() {
}
else
{
}
else
{
// Default date : tomorrow
// Default date : tomorrow
let
date_object
=
new
Date
();
let
date_object
=
new
Date
();
date_object
.
setDate
(
date_object
.
getDate
()
+
1
);
date_object
.
setDate
(
date_object
.
getDate
()
+
1
);
// Get ISO format bare string
// Get ISO format bare string
formatted_date
=
date_object
.
toISOString
().
replace
(
'T'
,
' '
).
split
(
'.'
)[
0
];
formatted_date
=
date_object
.
toISOString
().
replace
(
'T'
,
' '
)
.
split
(
'.'
)[
0
];
}
}
// Create an entry for this supplier
// Create an entry for this supplier
orders_data
.
suppliers_data
[
supplier
.
id
]
=
{
orders_data
.
suppliers_data
[
supplier
.
id
]
=
{
date_planned
:
formatted_date
,
date_planned
:
formatted_date
,
lines
:
[]
lines
:
[]
}
}
;
}
}
openModal
();
openModal
();
...
@@ -857,7 +868,7 @@ function create_orders() {
...
@@ -857,7 +868,7 @@ function create_orders() {
order_doc
.
_deleted
=
true
;
order_doc
.
_deleted
=
true
;
update_cdb_order
().
then
(()
=>
{
update_cdb_order
().
then
(()
=>
{
update_order_selection_screen
();
update_order_selection_screen
();
})
})
;
reset_data
();
reset_data
();
switch_screen
(
'orders_created'
);
switch_screen
(
'orders_created'
);
closeModal
();
closeModal
();
...
@@ -933,7 +944,7 @@ function goto_main_screen(doc) {
...
@@ -933,7 +944,7 @@ function goto_main_screen(doc) {
update_cdb_order
();
update_cdb_order
();
update_main_screen
();
update_main_screen
();
switch_screen
();
switch_screen
();
})
})
;
}
}
function
back
()
{
function
back
()
{
...
@@ -979,6 +990,7 @@ function display_suppliers() {
...
@@ -979,6 +990,7 @@ function display_suppliers() {
const
clicked_supplier
=
selected_suppliers
.
find
(
s
=>
s
.
id
==
supplier_id
);
const
clicked_supplier
=
selected_suppliers
.
find
(
s
=>
s
.
id
==
supplier_id
);
let
modal_remove_supplier
=
$
(
'#templates #modal_remove_supplier'
);
let
modal_remove_supplier
=
$
(
'#templates #modal_remove_supplier'
);
modal_remove_supplier
.
find
(
".supplier_name"
).
text
(
clicked_supplier
.
display_name
);
modal_remove_supplier
.
find
(
".supplier_name"
).
text
(
clicked_supplier
.
display_name
);
openModal
(
openModal
(
...
@@ -1036,11 +1048,12 @@ function _compute_product_data(product) {
...
@@ -1036,11 +1048,12 @@ function _compute_product_data(product) {
if
(
order_doc
.
coverage_days
!==
null
)
{
if
(
order_doc
.
coverage_days
!==
null
)
{
let
qty_not_covered
=
0
;
let
qty_not_covered
=
0
;
let
days_covered
=
0
;
let
days_covered
=
0
;
if
(
product
.
daily_conso
!==
0
)
{
if
(
product
.
daily_conso
!==
0
)
{
qty_not_covered
=
product
.
daily_conso
*
order_doc
.
coverage_days
-
product
.
qty_available
-
product
.
incoming_qty
-
purchase_qty
;
qty_not_covered
=
product
.
daily_conso
*
order_doc
.
coverage_days
-
product
.
qty_available
-
product
.
incoming_qty
-
purchase_qty
;
qty_not_covered
=
-
Math
.
ceil
(
qty_not_covered
);
// round up, so if a value is not fully covered display it
qty_not_covered
=
-
Math
.
ceil
(
qty_not_covered
);
// round up, so if a value is not fully covered display it
qty_not_covered
=
(
qty_not_covered
>
0
)
?
0
:
qty_not_covered
;
// only display qty not covered (neg value)
qty_not_covered
=
(
qty_not_covered
>
0
)
?
0
:
qty_not_covered
;
// only display qty not covered (neg value)
days_covered
=
(
product
.
qty_available
+
product
.
incoming_qty
+
purchase_qty
)
/
product
.
daily_conso
;
days_covered
=
(
product
.
qty_available
+
product
.
incoming_qty
+
purchase_qty
)
/
product
.
daily_conso
;
days_covered
=
Math
.
floor
(
days_covered
);
days_covered
=
Math
.
floor
(
days_covered
);
}
}
...
@@ -1224,7 +1237,7 @@ function prepare_datatable_columns() {
...
@@ -1224,7 +1237,7 @@ function prepare_datatable_columns() {
},
},
width
:
"4%"
width
:
"4%"
});
});
return
columns
;
return
columns
;
}
}
...
@@ -1265,8 +1278,20 @@ function display_products(params) {
...
@@ -1265,8 +1278,20 @@ function display_products(params) {
stripeClasses
:
[],
// Remove datatable cells coloring
stripeClasses
:
[],
// Remove datatable cells coloring
orderClasses
:
false
,
orderClasses
:
false
,
aLengthMenu
:
[
aLengthMenu
:
[
[
25
,
50
,
100
,
200
,
-
1
],
[
[
25
,
50
,
100
,
200
,
"Tout"
]
25
,
50
,
100
,
200
,
-
1
],
[
25
,
50
,
100
,
200
,
"Tout"
]
],
],
iDisplayLength
:
-
1
,
iDisplayLength
:
-
1
,
scrollX
:
true
,
scrollX
:
true
,
...
@@ -1468,8 +1493,10 @@ function display_total_values() {
...
@@ -1468,8 +1493,10 @@ function display_total_values() {
_compute_total_values_by_supplier
();
_compute_total_values_by_supplier
();
let
order_total_value
=
0
;
let
order_total_value
=
0
;
for
(
let
supplier
of
selected_suppliers
)
{
for
(
let
supplier
of
selected_suppliers
)
{
$
(
`#pill_supplier_
${
supplier
.
id
}
`
).
find
(
'.supplier_total_value'
).
text
(
parseFloat
(
supplier
.
total_value
).
toFixed
(
2
));
$
(
`#pill_supplier_
${
supplier
.
id
}
`
).
find
(
'.supplier_total_value'
)
.
text
(
parseFloat
(
supplier
.
total_value
).
toFixed
(
2
));
order_total_value
+=
supplier
.
total_value
;
order_total_value
+=
supplier
.
total_value
;
}
}
...
@@ -1525,8 +1552,9 @@ function update_order_selection_screen() {
...
@@ -1525,8 +1552,9 @@ function update_order_selection_screen() {
}).
then
(
function
(
result
)
{
}).
then
(
function
(
result
)
{
// Remove listener before recreating them
// Remove listener before recreating them
$
(
".order_pill"
).
off
();
$
(
".order_pill"
).
off
();
let
existing_orders_container
=
$
(
"#existing_orders"
);
let
existing_orders_container
=
$
(
"#existing_orders"
);
existing_orders_container
.
empty
();
existing_orders_container
.
empty
();
$
(
'#new_order_name'
).
val
(
''
);
$
(
'#new_order_name'
).
val
(
''
);
...
@@ -1535,6 +1563,7 @@ function update_order_selection_screen() {
...
@@ -1535,6 +1563,7 @@ function update_order_selection_screen() {
}
else
{
}
else
{
for
(
let
row
of
result
.
rows
)
{
for
(
let
row
of
result
.
rows
)
{
let
template
=
$
(
"#templates #order_pill_template"
);
let
template
=
$
(
"#templates #order_pill_template"
);
template
.
find
(
".pill_order_name"
).
text
(
row
.
id
);
template
.
find
(
".pill_order_name"
).
text
(
row
.
id
);
existing_orders_container
.
append
(
template
.
html
());
existing_orders_container
.
append
(
template
.
html
());
...
@@ -1653,9 +1682,9 @@ $(document).ready(function() {
...
@@ -1653,9 +1682,9 @@ $(document).ready(function() {
e
.
preventDefault
();
e
.
preventDefault
();
if
(
is_time_to
(
'submit_coverage_form'
,
1000
))
{
if
(
is_time_to
(
'submit_coverage_form'
,
1000
))
{
let
val
=
$
(
"#coverage_days_input"
).
val
();
let
val
=
$
(
"#coverage_days_input"
).
val
();
val
=
parseInt
(
val
);
val
=
parseInt
(
val
);
if
(
!
isNaN
(
val
))
{
if
(
!
isNaN
(
val
))
{
order_doc
.
coverage_days
=
val
;
order_doc
.
coverage_days
=
val
;
compute_products_coverage_qties
();
compute_products_coverage_qties
();
...
@@ -1698,18 +1727,19 @@ $(document).ready(function() {
...
@@ -1698,18 +1727,19 @@ $(document).ready(function() {
$
(
'#create_orders'
).
on
(
'click'
,
function
()
{
$
(
'#create_orders'
).
on
(
'click'
,
function
()
{
if
(
is_time_to
(
'create_orders'
,
1000
))
{
if
(
is_time_to
(
'create_orders'
,
1000
))
{
let
modal_create_order
=
$
(
'#templates #modal_create_order'
);
let
modal_create_order
=
$
(
'#templates #modal_create_order'
);
modal_create_order
.
find
(
'.suppliers_date_planned_area'
).
empty
();
modal_create_order
.
find
(
'.suppliers_date_planned_area'
).
empty
();
for
(
let
supplier
of
selected_suppliers
)
{
for
(
let
supplier
of
selected_suppliers
)
{
let
supplier_date_planned_template
=
$
(
'#templates #modal_create_order__supplier_date_planned'
);
let
supplier_date_planned_template
=
$
(
'#templates #modal_create_order__supplier_date_planned'
);
supplier_date_planned_template
.
find
(
".supplier_name"
).
text
(
supplier
.
display_name
);
supplier_date_planned_template
.
find
(
".supplier_name"
).
text
(
supplier
.
display_name
);
supplier_date_planned_template
.
find
(
".modal_input_container"
).
attr
(
'id'
,
`container_date_planned_supplier_
${
supplier
.
id
}
`
);
supplier_date_planned_template
.
find
(
".modal_input_container"
).
attr
(
'id'
,
`container_date_planned_supplier_
${
supplier
.
id
}
`
);
modal_create_order
.
find
(
'.suppliers_date_planned_area'
).
append
(
supplier_date_planned_template
.
html
());
modal_create_order
.
find
(
'.suppliers_date_planned_area'
).
append
(
supplier_date_planned_template
.
html
());
}
}
openModal
(
openModal
(
modal_create_order
.
html
(),
modal_create_order
.
html
(),
()
=>
{
()
=>
{
...
@@ -1720,12 +1750,13 @@ $(document).ready(function() {
...
@@ -1720,12 +1750,13 @@ $(document).ready(function() {
'Valider'
,
'Valider'
,
false
false
);
);
// Add id to input once modal is displayed
// Add id to input once modal is displayed
for
(
let
supplier
of
selected_suppliers
)
{
for
(
let
supplier
of
selected_suppliers
)
{
$
(
`#modal #container_date_planned_supplier_
${
supplier
.
id
}
`
).
find
(
".supplier_date_planned"
).
attr
(
'id'
,
`date_planned_supplier_
${
supplier
.
id
}
`
);
$
(
`#modal #container_date_planned_supplier_
${
supplier
.
id
}
`
).
find
(
".supplier_date_planned"
)
.
attr
(
'id'
,
`date_planned_supplier_
${
supplier
.
id
}
`
);
}
}
$
(
"#modal .supplier_date_planned"
)
$
(
"#modal .supplier_date_planned"
)
.
datepicker
({
.
datepicker
({
defaultDate
:
"+1d"
,
defaultDate
:
"+1d"
,
...
@@ -1741,7 +1772,7 @@ $(document).ready(function() {
...
@@ -1741,7 +1772,7 @@ $(document).ready(function() {
}
}
});
});
}
}
return
0
;
return
0
;
});
});
...
...
outils/config.md
View file @
301b9756
...
@@ -230,8 +230,11 @@
...
@@ -230,8 +230,11 @@
-
ENTRANCE_EXTRA_BUTTONS_DISPLAY = False (no button is shown above shift coop. list) (True if not set)
-
ENTRANCE_EXTRA_BUTTONS_DISPLAY = False (no button is shown above shift coop. list) (True if not set)
-
ENTRANCE_EASY_SHIFT_VALIDATE = False (default value)
When set to True allow coop to identify and have 1 point (only if FTOP)
-
ENTRANCE_EASY_SHIFT_VALIDATE = False (default value)
When set to True allow coop to identify and have 1 point (only if FTOP)
-
ENTRANCE_ADD_PT_EVENT_NAME = 'Add 1 point name throught easy validate' (default : 'Validation service comité'')
### Member space
### Member space
-
EM_URL = ''
-
EM_URL = ''
...
...
outils/static/js/all_common.js
View file @
301b9756
...
@@ -59,10 +59,9 @@ function post_form(url, data, callback) {
...
@@ -59,10 +59,9 @@ function post_form(url, data, callback) {
$
.
post
(
ajax_params
)
$
.
post
(
ajax_params
)
.
done
(
function
(
rData
)
{
.
done
(
function
(
rData
)
{
callback
(
null
,
rData
);
callback
(
null
,
rData
);
})
})
.
fail
(
function
(
err
)
{
.
fail
(
function
(
err
)
{
c
onsole
.
log
(
err
);
c
allback
(
err
,
{}
);
});
});
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment