responsive on edit forms

This commit is contained in:
ty kayn 2019-06-12 14:13:36 +02:00
parent 91c89165c3
commit ca5f297077
16 changed files with 985 additions and 685 deletions

View File

@ -17,11 +17,12 @@
{% block bigMain %} {% block bigMain %}
{% include 'default/header.html.twig' %} {% include 'default/header.html.twig' %}
<div class="container"> <div class="row-fluid">
<div class="col-xs-12 col-sm-9 col-sm-offset-2">
{% block body %} {% block body %}
{% endblock %} {% endblock %}
</div> </div>
</div>
{% include 'default/footer.html.twig' %} {% include 'default/footer.html.twig' %}
{% endblock %} {% endblock %}
</div> </div>

View File

@ -5,7 +5,7 @@
{% if is_granted("IS_AUTHENTICATED_REMEMBERED") %} {% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
<div class="row"> <div class="row">
<div class="col-xs-9"> <div class="col-xs-12 col-sm-9">
<div id="menu-dashboard"> <div id="menu-dashboard">
<ul class="nav"> <ul class="nav">
<li> <li>
@ -109,7 +109,12 @@
</ul> </ul>
</div> </div>
</div> </div>
<div class="col-xs-3 text-right"> <div class="col-xs-12 col-sm-3 text-sm-left text-md-right">
<button class="btn btn-default visible-xs pull-right" id="menu_button">
<i class="fa fa-bars"></i>
Menu
</button>
{% trans %}user.greet{% endtrans %} {% trans %}user.greet{% endtrans %}
<a href="{{ path('fos_user_profile_edit') }}"> <a href="{{ path('fos_user_profile_edit') }}">

View File

@ -1,47 +1,50 @@
{% verbatim %}
<div class="current-selling"> <div class="current-selling">
<form> <form>
<div class="row">
<div class="col-xs-12 col-sm-6">
<h2> <h2>
<a class="btn " href="{{ path('festival_index') }}">
Festival: {% verbatim %}
<i class="fa fa-th-large"></i>
Festival
</a>:
<span class="badge" title="fond de caisse + chiffre d'affaire. veillez à vider votre fond de caisse ailleurs lorsqu'il devient trop important, par exemple au dela de 200€" ng-class="{'badge-warning': activeFestival.fondDeCaisseAvant + activeFestival.chiffreAffaire > 200}"> <span class="badge" title="fond de caisse + chiffre d'affaire. veillez à vider votre fond de caisse ailleurs lorsqu'il devient trop important, par exemple au dela de 200€" ng-class="{'badge-warning': activeFestival.fondDeCaisseAvant + activeFestival.chiffreAffaire > 200}">
<i class="fa fa-archive"></i> <i class="fa fa-archive"></i>
{{ activeFestival.fondDeCaisseAvant + activeFestival.chiffreAffaire}} € {{ activeFestival.fondDeCaisseAvant + activeFestival.chiffreAffaire}} €
</span> </span>
<span class="badge badge-success">CA {{ activeFestival.chiffreAffaire }} <span class="badge badge-success">
CA {{ activeFestival.chiffreAffaire }}
<span ng-if="sellingOk"> <span ng-if="sellingOk">
<i class="fa fa-check-circle-o"></i> <i class="fa fa-check-circle-o"></i>
</span> </span>
</span> </span>
<span class="badge badge-success">{{ activeFestival.clientsCount }} <i class="fa fa-user"></i></span> <span class="badge badge-success">{{ activeFestival.clientsCount }} <i class="fa fa-user"></i></span>
</h2> </h2>
</div>
<div class="col-xs-12 col-sm-6">
<input type="text" ng-model="activeFestival.name" placeholder="nom du festival"> <input type="text" ng-model="activeFestival.name" placeholder="nom du festival">
<input type="text" ng-model="activeFestival.commentaire" placeholder="commentaire"> <input class="pull-right" type="text" ng-model="activeFestival.commentaire" placeholder="commentaire">
</div>
</div>
<hr> <hr>
<div>
<div class="row-fluid">
</div>
</div>
</div> </div>
<div class="new-display"> <div class="new-display">
<div class="row"> <div class="row">
<!-- <div class="col-xs-12 col-sm-6">-->
<!-- <h2>new display without duplicates:</h2>-->
<!-- </div>-->
<div class="col-xs-12 col-sm-6"> <div class="col-xs-12 col-sm-6">
<h2>new display without duplicates:</h2> <button class="btn btn-warning btn-remove-all" ng-click="removeAll()" ng-disable="!CurrentSellingTotal()">
</div> <i class="fa fa-trash"></i> enlever tout
<div class="col-xs-12 col-sm-6">
<button class="btn btn-warning" ng-click="removeAll()" ng-disable="!CurrentSellingTotal()">
<i class="fa fa-trash"></i> enlever Tout
</button> </button>
</div> </div>
</div> </div>
@ -49,12 +52,12 @@
<div ng-repeat="group in activeSellingFiltered track by $index"> <div ng-repeat="group in activeSellingFiltered track by $index">
<div class="row"> <div class="row">
<div class="col-xs-12 col-sm-4"> <div class="col-xs-4">
<div class="input-group"> <div class="input-group">
<input type="text" ng-model="group.name"> <input type="text" ng-model="group.name">
</div> </div>
</div> </div>
<div class="col-xs-12 col-sm-4 text-right"> <div class="col-xs-4 text-right">
<strong> <strong>
{{group.unitPrice}} {{group.unitPrice}}
€ </strong> € </strong>
@ -62,9 +65,8 @@
<i class="fa fa-times"></i> {{group.count}} <i class="fa fa-times"></i> {{group.count}}
</span> </span>
</div> </div>
<div class="col-xs-12 col-sm-4 text-right"> <div class="col-xs-4 text-right">
<strong> <strong>
<!--<input type="number" ng-model="p.price">-->
{{group.totalPrice}} {{group.totalPrice}}
€ </strong> € </strong>
<span class="btn btn-warning remove-item" <span class="btn btn-warning remove-item"
@ -77,76 +79,12 @@
</div> </div>
<hr> <hr>
<div class="text-right">
<div class="row clickable" >
<div class="col-xs-12 col-sm-6">
<h3 ng-click="setRightAmountPaid()">Total: </h3>
</div>
<div class="col-xs-12 col-sm-6">
<h3 ng-click="setRightAmountPaid()">
<strong>
{{ CurrentSellingTotal() }}
</strong>€
</h3>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6">
Le client paie:
</div>
<div class="col-xs-12 col-sm-6">
<input type="number" id="paid_amount" ng-model="paidAmount">
</div>
</div>
<div class="alert alert-success" ng-if="paidAmount && CurrentSellingTotal() - paidAmount <=0">
<h3>Rendu: {{ -1*(CurrentSellingTotal() - paidAmount) }} €</h3>
</div>
<div class="alert alert-warning" ng-if="paidAmount && CurrentSellingTotal() - paidAmount >0">
<h3>il manque: {{ CurrentSellingTotal() - paidAmount }} €</h3>
</div>
</div>
<div class="row">
<div class="col">
{% endverbatim %} {% endverbatim %}
{% include 'logged/angular/totals.html.twig' %}
{% include 'logged/angular/validate-button.html.twig' %} {% include 'logged/angular/validate-button.html.twig' %}
{% include 'logged/angular/pause-selling.html.twig' %}
{% verbatim %} {% verbatim %}
</div>
<!--<div class="col">-->
<!--<button class="btn btn-default" id="pause_selling" ng-click="pauseSelling()">-->
<!--<i class="fa fa-clock"></i>-->
<!--Pause-->
<!--</button>-->
<!--</div>-->
</div>
<div class="old-display well">
<!--<h2>old display:</h2>-->
<!--<div ng-repeat="p in activeSelling track by $index">-->
<!--<div class="row">-->
<!--<div class="col-xs-12 col-sm-6">-->
<!--<div class="input-group">-->
<!--<input type="text" ng-model="p.name">-->
<!--<span class="btn btn-warning input-group-addon remove-item"-->
<!--ng-click="removeProduct(p,$index)">-->
<!--<i class="fa fa-trash"></i>-->
<!--</span>-->
<!--</div>-->
<!--</div>-->
<!--<div class="col-xs-12 col-sm-6 text-right">-->
<!--<strong>-->
<!--<input type="number" ng-model="p.price">-->
<!--€ </strong>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
</div>
</form> </form>
<hr>
</div> </div>
{% endverbatim %} {% endverbatim %}

View File

@ -0,0 +1,8 @@
{% verbatim %}
<!--<div class="col">-->
<!--<button class="btn btn-default" id="pause_selling" ng-click="pauseSelling()">-->
<!--<i class="fa fa-clock"></i>-->
<!--Pause-->
<!--</button>-->
<!--</div>-->
{% endverbatim %}

View File

@ -0,0 +1,30 @@
{% verbatim %}
<div class="text-right">
<div class="row clickable" >
<div class="col-xs-12 col-sm-6">
<h3 ng-click="setRightAmountPaid()">Total: </h3>
</div>
<div class="col-xs-12 col-sm-6">
<h3 ng-click="setRightAmountPaid()">
<strong>
{{ CurrentSellingTotal() }}
</strong>€
</h3>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6">
Le client paie:
</div>
<div class="col-xs-12 col-sm-6">
<input class="text-right" type="number" id="paid_amount" ng-model="paidAmount">
</div>
</div>
<div class="alert alert-success" ng-if="paidAmount && CurrentSellingTotal() - paidAmount <=0">
<h3>Rendu: {{ -1*(CurrentSellingTotal() - paidAmount) }} €</h3>
</div>
<div class="alert alert-warning" ng-if="paidAmount && CurrentSellingTotal() - paidAmount >0">
<h3>il manque: {{ CurrentSellingTotal() - paidAmount }} €</h3>
</div>
</div>
{% endverbatim %}

View File

@ -1,3 +1,4 @@
{% verbatim %}
<button class="btn btn-primary btn-block validate_selling" ng-click="sendForm(event)" <button class="btn btn-primary btn-block validate_selling" ng-click="sendForm(event)"
ng-disabled="!paidAmount"> ng-disabled="!paidAmount">
<i class="fa fa-check"></i> <i class="fa fa-check"></i>
@ -9,3 +10,4 @@
<i class="fa fa-warning"></i> <i class="fa fa-warning"></i>
</span> </span>
</button> </button>
{% endverbatim %}

View File

@ -6,11 +6,13 @@
</div> </div>
{% endverbatim %} {% endverbatim %}
{% include 'logged/angular/loaded-caisse.html.twig' %} {% include 'logged/angular/loaded-caisse.html.twig' %}
{% verbatim %}
<div class="choice-categories well" ng-if="categories.length"> <div class="choice-categories well" ng-if="categories.length">
<h2> <h2>
<i class="fa-eye fa"></i> <i class="fa-eye fa"></i>
Visibilité des catégories Visibilité des
{{categories.length - categoriesVisibleCount() }} /
{{ categories.length }} catégories
</h2> </h2>
<div ng-repeat="c in categories" <div ng-repeat="c in categories"
@ -18,10 +20,15 @@
<div class="btn btn-block" <div class="btn btn-block"
ng-class="{'btn-success': !c.hidden}" ng-class="{'btn-success': !c.hidden}"
ng-click="c.hidden = !c.hidden"> ng-click="c.hidden = !c.hidden">
{% verbatim %} {{ c.name }} {{ c.name }}
{% endverbatim %}
<span ng-if="c.hidden">(caché)</span> <span ng-if="c.hidden">(caché)</span>
</div> </div>
</div> </div>
</div> </div>
<div class="well" ng-if="!categories.length">
<i class="fa fa-info"></i>
Aucune catégorie enregistrée
</div>
{% endverbatim %}

View File

@ -1,13 +1,12 @@
{% extends 'base.html.twig' %} {% extends 'base.html.twig' %}
{% block body %} {% block body %}
<div id="wrapper">
<div id="caisse-now" class="tab-pane fade in active"> <div id="caisse-now" class="tab-pane fade in active">
<div class="caisse-main row" <div class="caisse-main row-fluid"
ng-app="caisse" ng-app="caisse"
ng-controller="CaisseCtrl as MainCtrl" ng-controller="CaisseCtrl as MainCtrl"
> >
<div class="row marged-v"> <div class="row marged-v">
<div class="col-xs-12 col-md-12"> <div class="col-xs-12 col-md-6">
<button <button
title="la vente express vous permet d'enregistrer une vente pour un seul article sans remplir le formulaire de détail" title="la vente express vous permet d'enregistrer une vente pour un seul article sans remplir le formulaire de détail"
class="btn" class="btn"
@ -41,43 +40,35 @@
</button> </button>
</div> </div>
<div class="col-xs-12 col-md-6"> <div class="col-xs-12 col-md-6">
<div class="row">
<div class="client-now text-right padded"> <div class="client-now text-right padded">
<div class="col-xs-12">
<i class="fa fa-user"></i> <i class="fa fa-user"></i>
Client actuel: Client actuel:
{% verbatim %} </div> {% verbatim %}
{{ activeSelling.length }} produit<span ng-if="activeSelling.length!=1">s</span> <div class="col-xs-10">
<div class="input-group pull-right"> <div class="input-group">
<input class="input form-control pull-right " type="text" ng-model="sellingComment" placeholder="nom ou commentaire">
<button type="button" class="pull-right deleter" ng-click="sellingComment = ''"> <input class="input form-control input-comment" type="text" ng-model="sellingComment" placeholder="nom ou commentaire">
<button type="button" class="deleter" ng-click="sellingComment = ''">
<i class="fa fa-times"></i> <i class="fa fa-times"></i>
</button> </button>
</div> </div>
<div> <div>
{{ activeSelling.length }} produit<span ng-if="activeSelling.length!=1">s</span>
{% endverbatim %} </div>{% endverbatim %}
{#<button class="btn btn-default" ng-click="sellingComment = 'boobbbbbb'">#} </div>
{#<i class="fa fa-arrow-right"></i>#}
{#</button>#}
{#<button class="btn btn-default"#}
{#ng-click="logger(MainCtrl.sellingComment ) ; logger( sellingComment)">#}
{#<i class="fa fa-arrow-down"></i>#}
{#</button>#}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
{% include 'logged/caisse-main.html.twig' %} {% include 'logged/caisse-main.html.twig' %}
</div> </div>
</div>
</div> </div>
<div id="categories" class="tab-pane fade"> <div id="categories" class="tab-pane fade">
<h2>Catégories</h2> <h2>Catégories</h2>

View File

@ -4,10 +4,10 @@
<div class="row"> <div class="row">
<div class="col-xs-6 well"> <div class="col-xs-12 col-sm-6 well">
{% include 'logged/mass-register.html.twig' %} {% include 'logged/mass-register.html.twig' %}
</div> </div>
<div class="col-xs-6 well"> <div class="col-xs-12 col-sm-6 well">
<h2> <h2>
Importer votre historique de ventes Importer votre historique de ventes

View File

@ -1,7 +1,7 @@
{% extends 'base.html.twig' %} {% extends 'base.html.twig' %}
{% block body %} {% block body %}
<h1>Productcategory creation</h1> <h1>Création de catégorie de produit</h1>
{{ form_start(form) }} {{ form_start(form) }}
{{ form_widget(form) }} {{ form_widget(form) }}

View File

@ -6,10 +6,12 @@
width: 100%; width: 100%;
float: left; float: left;
} }
.product-button { .product-button {
width: 80%; width: 80%;
text-overflow-ellipsis: "..."; text-overflow-ellipsis: "...";
} }
.listing-products { .listing-products {
.btn, button { .btn, button {
@ -22,21 +24,28 @@
border-color: $all-text-color; border-color: $all-text-color;
box-shadow: 5px 3px 10px 2px #ddd; box-shadow: 5px 3px 10px 2px #ddd;
border-width: 0; border-width: 0;
&.btn-primary { &.btn-primary {
background-color: $deepblue; background-color: $deepblue;
} }
&:hover { &:hover {
background: $lightblue; background: $lightblue;
} }
} }
.badge-default { .badge-default {
background: $lightblue; background: $lightblue;
} }
.badge-success { .badge-success {
background: mix(green, $lightblue); background: mix(green, $lightblue);
} }
} }
.input-comment {
width: calc(100% - 40px);
}
} }
// container of categories // container of categories
@ -44,7 +53,7 @@
overflow-x: auto; overflow-x: auto;
overflow-y: hidden; overflow-y: hidden;
//width: 100%; //width: 100%;
height: 80vh; height: 75vh;
background: #ccc; background: #ccc;
padding: 0.5rem; padding: 0.5rem;
} }
@ -54,23 +63,31 @@
background: #dedede; background: #dedede;
width: 350px; width: 350px;
margin: 0 4px; margin: 0 4px;
height: calc(80vh - 1rem); height: calc(74vh - 1rem);
box-sizing: border-box; box-sizing: border-box;
display: inline-block; display: inline-block;
//vertical-align: top; //vertical-align: top;
white-space: nowrap; white-space: nowrap;
//float: left; //float: left;
} }
.category-listing { .category-listing {
border: solid 1px $grey; border: solid 1px $grey;
padding: 1rem; padding: 1rem;
margin: 0.5rem; margin: 0.5rem;
border-radius: 0.25rem; border-radius: 0.25rem;
} }
.validate_selling { .validate_selling {
margin: 0.25rem; margin: 0.25rem;
} }
.product-listing { .product-listing {
height: 70vh; height: 70vh;
overflow: auto; overflow: auto;
} }
.sellings{
.remove-item{
margin-left: 1em;
}
}

View File

@ -40,7 +40,7 @@ code {
#wrapper { #wrapper {
background: #FFF; background: #FFF;
margin: 1em auto; margin: 1em auto;
max-width: 800px; //max-width: 800px;
width: 95%; width: 95%;
} }

View File

@ -46,9 +46,11 @@ body {
.bg-color { .bg-color {
background: $deepblue; background: $deepblue;
color: $light; color: $light;
a { a {
color: $lightblue; color: $lightblue;
} }
padding: 1rem; padding: 1rem;
} }
@ -84,6 +86,7 @@ label {
.padded { .padded {
padding: 1rem; padding: 1rem;
&-v { &-v {
padding: 0; padding: 0;
padding-top: 1rem; padding-top: 1rem;
@ -93,6 +96,7 @@ label {
.marged { .marged {
margin: 1rem; margin: 1rem;
&-v { &-v {
margin: 0; margin: 0;
margin-top: 1rem; margin-top: 1rem;
@ -117,23 +121,25 @@ label {
} }
.previsionnel { .previsionnel {
.config { font-size: 1rem;
font-size: 1.5rem; //.config {
} // font-size: 1.5rem;
thead { //}
font-size: 1.5rem; //thead {
} // font-size: 1.5rem;
//}
label { label {
min-width: 220px; min-width: 220px;
} }
.exepanse-table {
font-size: 1.5rem; //.exepanse-table {
} // font-size: 1.5rem;
.examples-depenses { //}
font-size: 1.5rem; //.examples-depenses {
} // font-size: 1.5rem;
//}
.big-number { .big-number {
font-size: 2.5rem; font-size: 1.85rem;
color: #2B2d42; color: #2B2d42;
} }
} }
@ -147,6 +153,7 @@ input {
width: auto; width: auto;
min-width: 2em; min-width: 2em;
} }
#menu-dashboard { #menu-dashboard {
background: $dark; background: $dark;
display: flex; display: flex;
@ -155,17 +162,23 @@ input {
top: 0; top: 0;
height: 100vh; height: 100vh;
width: 13vw; width: 13vw;
min-width: 300px;
overflow-x: auto; overflow-x: auto;
z-index: 10;
.nav { .nav {
width: 13vw; width: 100%;
min-width: 300px; min-width: 300px;
display: block; display: block;
border-right: solid 2px mix($dark, $grey); border-right: solid 2px mix($dark, $grey);
.btn { .btn {
color: $light; color: $light;
} }
.btn-default { .btn-default {
color: $light; color: $light;
&:hover { &:hover {
background: mix($deepblue, $light); background: mix($deepblue, $light);
color: $dark; color: $dark;
@ -173,43 +186,52 @@ input {
} }
} }
} }
i.fa { i.fa {
float: left; float: left;
margin-right: 1em; margin-right: 1em;
color: $light; color: $light;
} }
} }
.nav > li > a:hover, .nav > li > a { .nav > li > a:hover, .nav > li > a {
&:focus { &:focus {
background: transparent; background: transparent;
border: none; border: none;
color: $lightblue; color: $lightblue;
} }
&:focus { &:focus {
background: transparent; background: transparent;
border: none; border: none;
color: $lightblue; color: $lightblue;
} }
} }
.btn { .btn {
border: 0; border: 0;
} }
.btn-default { .btn-default {
background: transparent; background: transparent;
} }
.btn-success { .btn-success {
background-color: $deepblue; background-color: $deepblue;
font-weight: 800; font-weight: 800;
} }
.table > thead > tr > td, .table > thead > tr > td,
table td { table td {
padding: 0.5em; padding: 0.5em;
} }
.login-fosub { .login-fosub {
.padded { .padded {
padding: 3em; padding: 3em;
} }
input[type=submit] { input[type=submit] {
background: $primary; background: $primary;
color: $light; color: $light;
@ -218,6 +240,7 @@ table td{
padding: 1em; padding: 1em;
border: 0; border: 0;
width: 100%; width: 100%;
&:hover { &:hover {
background: $lightblue; background: $lightblue;
} }
@ -232,6 +255,14 @@ table td{
#bodyland { #bodyland {
.container { .container {
min-height: 1000px; min-height: 100vh;
} }
} }
#menu_button{
z-index: 10;
position: absolute;
right: 1em;
top: -2px;
font-size: 1rem;
}

View File

@ -1,4 +1,3 @@
@media all and(max-width: 1200px) { @media all and(max-width: 1200px) {
nav { nav {
min-width: auto; min-width: auto;
@ -18,6 +17,7 @@
.main-section { .main-section {
padding: 2rem; padding: 2rem;
} }
.btn { .btn {
display: block; display: block;
width: 100%; width: 100%;
@ -28,9 +28,11 @@
.product-box { .product-box {
width: 100%; width: 100%;
} }
.product-button { .product-button {
min-width: calc(100% - 56px) min-width: calc(100% - 56px)
} }
.listing-products { .listing-products {
.btn, button { .btn, button {
@ -42,12 +44,104 @@
} }
} }
@media all and(max-width: 600px) { @media all and(max-width: 1200px) {
html,body{
font-size: 1.5rem; #bodyland {
.container {
min-height: 100vh;
width: 80vw;
}
}
#menu-dashboard {
font-size: 1rem;
width: 19vw;
min-width: 200px;
.nav {
min-width: 200px;
}
}
form {
margin-top: 3em;
select {
width: 100%;
margin: 1em 0;
}
+ ul {
margin-top: 1em;
list-style-type: none;
a {
display: block;
.fa {
margin-right: 1em;
}
}
}
}
}
@media all and(max-width: 600px) {
html, body {
font-size: 1rem;
}
#menu-dashboard .nav .logo-home.btn-default {
height: auto;
font-size: 2em;
}
#menu-dashboard {
width: 100vw;
visibility: hidden;
&.shown {
visibility: visible;
}
.nav {
min-width: 200px;
height: 100vh;
overflow: auto;
a {
font-size: 2rem;
}
}
}
.category-listing {
width: calc(100vw - 9rem);
height: 25vh;
min-height: auto;
float: left;
clear: both;
overflow: auto;
}
.sellings, .client-now {
input {
width: 100%;
font-size: 1.5rem;
padding: 0.5rem;
}
}
.big-footer {
font-size: 1rem;
}
#caisse-now .product-box {
margin-bottom: 0.25rem;
}
#caisse-now .listing-products button {
padding: 0.5rem 1rem;
.express-button {
padding: 0.5rem 1rem;
} }
.category-listing{
width: calc(100% - 2rem);
} }
} }

View File

@ -10,12 +10,18 @@ require('bootstrap-sass');
$(document).ready(function () { $(document).ready(function () {
$('[data-toggle="popover"]').popover(); $('[data-toggle="popover"]').popover();
$('#menu_button').on('click', function(){
$('#menu-dashboard').toggleClass('shown');
})
}); });
require('./caisseCtrl');
require('./dashboard');
var PrevisionnelCtrl = require('./previsionnel');
console.log('hello console for main.js'); console.log('hello console for main.js');
var stuff = ['initialstuff']; var stuff = ['initialstuff'];
// TODO split controllers in other files // TODO split controllers in other files
angular angular
.module('caisse', []) .module('caisse', [])
@ -46,7 +52,6 @@ angular
commentaire : "" commentaire : ""
}; };
/** /**
* set the right paid amount * set the right paid amount
*/ */
@ -93,7 +98,7 @@ angular
$scope.sumOfList = function (list) { $scope.sumOfList = function (list) {
let counter = 0; let counter = 0;
for (let i = 0; i < list.length; i++) { for (let i = 0; i < list.length; i++) {
counter += list[i].price; counter += list[i].price * 1;
} }
return counter; return counter;
}; };
@ -106,6 +111,14 @@ angular
return $scope.sumOfList($scope.activeSelling); return $scope.sumOfList($scope.activeSelling);
}; };
$scope.categoriesVisibleCount = function () {
let count = 0;
$scope.categories.forEach(function (elem) {
elem.hidden ? count++ : "";
});
return count;
}
$scope.regenActiveSellingIds = function () { $scope.regenActiveSellingIds = function () {
$scope.activeItemsSold = []; $scope.activeItemsSold = [];
$scope.paidAmount = 0; $scope.paidAmount = 0;
@ -435,7 +448,7 @@ angular
console.error(error); console.error(error);
$scope.config.loading = false; $scope.config.loading = false;
} };
$scope.updateCanevas = function () { $scope.updateCanevas = function () {
var dataPoints = $scope.graphPointsPrevision; var dataPoints = $scope.graphPointsPrevision;
var chartContainer = new CanvasJS.Chart("simulationPrevision", { var chartContainer = new CanvasJS.Chart("simulationPrevision", {
@ -452,6 +465,6 @@ angular
] ]
}); });
chartContainer.render(); chartContainer.render();
} };
$scope.init(); $scope.init();
}]); }]);

View File

@ -0,0 +1,163 @@
export var PrevisionnelCtrl = function ($scope, $http, $timeout) {
$scope.config = {
initialLoadingDone : false,
loading : false,
lines : 24,
debounceTime : 300, // miliseconds to wait before updating model and saving changes
/**
* expenses kind of the user
*/
disponibility : 5000,
averageMonthlyEarnings: 600,
warningThershold : 2000,
showDelays : false,
showRepeats : false,
monthsBeforeNoMoney : null,
};
let exampleExpenses = [
{name: "appart", amount: 800, delay: 0, repeat: $scope.config.lines, enabled: true},
{name: "assurance voiture", amount: 50, delay: 0, repeat: $scope.config.lines, enabled: true},
{name: "internet", amount: 20, delay: 0, repeat: $scope.config.lines, enabled: true},
{name: "elec", amount: 100, delay: 0, repeat: $scope.config.lines, enabled: true},
{name: "chat", amount: 20, delay: 0, repeat: $scope.config.lines, enabled: true},
{name: "transports", amount: 70, delay: 0, repeat: $scope.config.lines, enabled: false},
];
// $scope.expenses=[];
$scope.expenses = exampleExpenses;
/**
* sum of all monthly expenses, ignoring delay
* @returns {number}
*/
$scope.sumMonthlyExpenses = () => {
let sum = 0;
$scope.expenses.forEach((elem) => {
if (elem.enabled) {
sum += elem.amount;
}
})
return sum;
};
$scope.previsionTable = [];
$scope.calculatePrevisionTable = () => {
let turns = $scope.config.lines;
let monthly = $scope.sumMonthlyExpenses();
let available = $scope.config.disponibility;
let previsionTable = [];
let changedNoMoneyConfig = false;
$scope.config.monthsBeforeNoMoney = null;
for (let i = 0; i <= turns; i++) {
// TODO take in account delays in expenses
available = available - monthly + $scope.config.averageMonthlyEarnings;
let newLine = {
expense : monthly,
available: available,
};
if (available <= 0 && !changedNoMoneyConfig) {
$scope.config.monthsBeforeNoMoney = i;
changedNoMoneyConfig = true;
}
previsionTable.push(newLine);
}
$scope.previsionTable = previsionTable;
$scope.makeGraphPointsOfPrevisionTable(previsionTable);
return previsionTable;
};
$scope.graphPointsPrevision = [];
$scope.makeGraphPointsOfPrevisionTable = (previsionTable) => {
console.log("previsionTable", previsionTable);
$scope.graphPointsPrevision = [];
for (let i = 0; i < previsionTable.length; i++) {
$scope.graphPointsPrevision.push({
label: previsionTable[i].available + " euros restants dans " + i + " mois",
y : previsionTable[i].available,
x : i,
})
}
}
$scope.updateconf = (rep) => {
// update view calculs
$scope.calculatePrevisionTable();
$scope.updateCanevas()
// flags
$scope.config.loading = false;
$scope.config.initialLoadingDone = true;
$scope.config.disponibility = rep.data.disponibility;
$scope.config.averageMonthlyEarnings = rep.data.averageMonthlyEarnings;
// default data when user has nothing saved
console.log('rep.data.expenses.length', rep.data.expenses.length)
if (!rep.data.expenses.length) {
$scope.expenses = exampleExpenses;
} else {
$scope.expenses = rep.data.expenses;
}
};
// http related calls
$scope.fetchExpenses = () => {
console.log('fetch expenses...');
$scope.config.loading = true;
$http.get('get-my-expenses').then((rep) => {
console.log('get-my-expenses', rep.data.expenses);
$scope.updateconf(rep)
},
$scope.manageError)
};
$scope.save = function () {
if ($scope.config.loading) {
console.log('already saving');
return;
}
console.log('update expenses...');
$scope.config.loading = true;
$http.post('save-my-expenses', {
expenses: $scope.expenses,
config : $scope.config
})
.then((rep) => {
console.log('save-my-expenses', rep);
$scope.updateconf(rep)
},
$scope.manageError)
};
$scope.addExpense = function () {
$scope.expenses.push({
name : "",
repeat: 0,
delay : 0,
amount: 0,
})
};
$scope.init = function () {
$scope.fetchExpenses();
};
$scope.manageError = (error) => {
console.error(error);
$scope.config.loading = false;
}
$scope.updateCanevas = function () {
var dataPoints = $scope.graphPointsPrevision;
var chartContainer = new CanvasJS.Chart("simulationPrevision", {
title: {
text: "Euros disponibles dans le temps"
},
// animationEnabled: true,
data : [
{
// Change type to "doughnut", "line", "splineArea", etc.
type : "splineArea",
dataPoints: dataPoints
}
]
});
chartContainer.render();
}
$scope.init();
};