Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tickets #414

Closed
wants to merge 10 commits into from
Closed
1 change: 1 addition & 0 deletions core/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function set_session(array $user, array $structure) {
$_SESSION['taux_tva'] = $structure['taux_tva'];
$_SESSION['structure'] = $structure['nom'];
$_SESSION['siret'] = $structure['siret'];
$_SESSION['tel'] = $structure['telephone'];
$_SESSION['adresse'] = $structure['adresse'];
$_SESSION['texte_adhesion'] = $structure['texte_adhesion'];
$_SESSION['lot_caisse'] = $structure['lot'];
Expand Down
39 changes: 39 additions & 0 deletions css/ticket_impression.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@page {
size: 8cm 15cm ;
}
html {
font-family: sans-serif;
font-size: 0.5rem;
}
p {
font-size: 1rem;
}

table {
table-layout: fixed;
width: 300px;
border-collapse: separate;
border: 2px solid black;
}

td, th {
border: 1px solid black;
padding: 5px 2px;
text-align: center;
}

th {
background-color: rgb(235,235,235);
}

td {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}



caption {
caption-side: bottom;
}
3 changes: 3 additions & 0 deletions ifaces/ventes.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ class="btn btn-default <?= (!empty($objs)) ? 'dropdown-toggle' : '' ?>"
window.OressourceEnv = {
structure: <?= json_encode($_SESSION['structure']) ?>,
adresse: <?= json_encode($_SESSION['adresse']) ?>,
siret: <?= json_encode($_SESSION['siret']) ?>,
tel: <?= json_encode($_SESSION['tel']) ?>,
nb_viz_caisse: <?= json_encode($_SESSION['nb_viz_caisse'], JSON_NUMERIC_CHECK); ?>,
force_pes_vente: <?= json_encode($_SESSION['force_pes_vente']); ?>,
pesees: <?= json_encode(pesees_ventes()) ?>,
Expand All @@ -274,6 +276,7 @@ class="btn btn-default <?= (!empty($objs)) ? 'dropdown-toggle' : '' ?>"
taux_tva: <?= json_encode($_SESSION['taux_tva'], JSON_NUMERIC_CHECK); ?>,
point: <?= json_encode(points_ventes_id($bdd, $numero), JSON_NUMERIC_CHECK); ?>,
id_user: <?= json_encode($_SESSION['id'], JSON_NUMERIC_CHECK) ?>,
nom_user: <?= json_encode($_SESSION['nom'], JSON_NUMERIC_CHECK) ?>,
moyens_paiement: <?= json_encode($moyens_paiement, JSON_NUMERIC_CHECK) ?>
};

Expand Down
Empty file modified js/bootstrap-switch.js
100644 → 100755
Empty file.
Empty file modified js/bootstrap.js
100644 → 100755
Empty file.
Empty file modified js/bootstrap.min.js
100644 → 100755
Empty file.
Empty file modified js/bower.json
100644 → 100755
Empty file.
Empty file modified js/daterangepicker.js
100644 → 100755
Empty file.
Empty file modified js/font-awesome.min.css
100644 → 100755
Empty file.
Empty file modified js/fr.js
100644 → 100755
Empty file.
Empty file modified js/index.php
100644 → 100755
Empty file.
Empty file modified js/jquery-2.1.1.min.js
100644 → 100755
Empty file.
Empty file modified js/jquery-2.1.1.min.map
100644 → 100755
Empty file.
Empty file modified js/moment.js
100644 → 100755
Empty file.
Empty file modified js/morris/.gitignore
100644 → 100755
Empty file.
Empty file modified js/morris/.travis.yml
100644 → 100755
Empty file.
Empty file modified js/morris/README.md
100644 → 100755
Empty file.
Empty file modified js/morris/component.json
100644 → 100755
Empty file.
Empty file modified js/morris/grunt.js
100644 → 100755
Empty file.
Empty file modified js/morris/morris.css
100644 → 100755
Empty file.
Empty file modified js/morris/morris.js
100644 → 100755
Empty file.
Empty file modified js/morris/morris.min.js
100644 → 100755
Empty file.
Empty file modified js/morris/package.json
100644 → 100755
Empty file.
Empty file modified js/morris/specs.html
100644 → 100755
Empty file.
Empty file modified js/numpad.js
100644 → 100755
Empty file.
Empty file modified js/raphael.js
100644 → 100755
Empty file.
Empty file modified js/ticket.js
100644 → 100755
Empty file.
44 changes: 27 additions & 17 deletions js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ function prepare_data(tickets, metadata) {
* Code de gestion de l'impression
*/

const dashBreak = '<p>--------------------------------------------------------------------------------</p>';
const dashBreak = '<p>-----------------------------------</p>';

/**
* Fonction qui permet d'afficher les différents types de Tickets dans le cas des pesées qui
Expand All @@ -559,7 +559,7 @@ const dashBreak = '<p>----------------------------------------------------------
*/
function showTickets(data, unit = 'kg') {
const item = (data.hasOwnProperty('items') && data.items.length > 0
? `<p>Objets</p>${dashBreak}${showTicket(data.items, window.OressourceEnv.types_dechet, unit)}`
? `${dashBreak}${showTicket(data.items, window.OressourceEnv.types_dechet, unit)}`
: '');
return item + (data.hasOwnProperty('evacs') && data.evacs.length > 0
? `<p>Matériaux</p>${dashBreak}${showTicket(data.evacs, window.OressourceEnv.types_evac, unit)}`
Expand Down Expand Up @@ -627,25 +627,35 @@ function impressionTicket(data, response, unit = 'kg', tvaStuff = () => '', sumF
<head>
<meta charset="utf-8">
<title>Ticket ${title} &#x2116;${response.id}</title>
<style>
size: 21cm 29.7cm;
margin: 30mm 45mm 30mm 45mm;
p {
font-size: 8px;
}
</style>
<link rel="stylesheet" href="../css/ticket_impression.css" type="text/css">
</head>
<body>
<p>${document.querySelector('h1').innerHTML}</p>
<p>${window.OressourceEnv.structure}</p>
<p>${window.OressourceEnv.adresse}</p>
<h1>${window.OressourceEnv.structure}</h1>
<h2>${document.querySelector('h1').innerHTML}<br>
${window.OressourceEnv.adresse}<br>
SIRET : ${window.OressourceEnv.siret}<br>
tel : ${window.OressourceEnv.tel}</h2>
${dashBreak}
<p>Type: ${classeToName(data.classe)} &#x2116;${response.id}</p>
<h2>Type: ${classeToName(data.classe)} &#x2116;${response.id}<br}>
Le : ${moment().format('DD/MM/YYYY - HH:mm')}<br>
Caisse : ${window.OressourceEnv.nom_user}</h2>
${tvaStuff()}
${showPaiement(data.id_moyen)}
<p>Ticket client à conserver.</p>
<p>Date d'édition du ticket : ${moment().format('DD/MM/YYYY - HH:mm')}</p>
${showTickets(data, unit)}
<p>${showPaiement(data.id_moyen)}<br>
Nb articles : ${state.ticket.sum_quantite()}</p>
${dashBreak}
<h2>Détail des articles</h2>
<table>
<caption>Nombre de lignes éditées : ${data.items.length} </caption>
<tr>
<th width= "5px"> Qte </th>
<th width= "20px"> Nom objet </th>
<th width= "8px"> P.U. € </th>
<th width= "10px"> Total </th>
</tr>
${showTickets(data, unit)}
</table>
${dashBreak}
<p>Ticket client à conserver.</p>
</body>
</html>`;

Expand Down
17 changes: 13 additions & 4 deletions js/ventes.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,13 @@ const printTva = (() => {
const ttc = state.ticket.sum_prix();
const taux_tva = window.OressourceEnv.taux_tva;
const ht = (ttc * 100) / (100 + taux_tva);
return `Prix HT. = ${ht.toFixed(2)} €<br> Prix TTC. = ${ttc.toFixed(2)} €<br\> dont TVA ${taux_tva}% = ${part_tva.toFixed(2)} €`;
const part_tva = ttc - ht;
return `<h2> Prix TTC = ${ttc.toFixed(2)} €<br> Prix HT. = ${ht.toFixed(2)} €<br> TVA ${taux_tva}% = ${part_tva.toFixed(2)} € </h2>`;
};
} else {
return () => {
const ht = state.ticket.sum_prix();
return `Prix HT. = ${ht.toFixed(2)} €<br\>Association non assujettie à la TVA.`;
return `<h2>Prix HT = ${ht.toFixed(2)} €<br>Association non assujettie à la TVA.</h2>`;
};
}
})();
Expand Down Expand Up @@ -419,6 +420,7 @@ function add() {

const name = current.objet.nom || current.type.nom;
const lotTxt = !state.vente_unite ? 'lot' : '';
const montant = quantite * prix;
const vente = {
id_type: current.type.id,
id_objet: current.objet.id || null,
Expand All @@ -427,14 +429,21 @@ function add() {
prix,
masse,
name, // Hack pour les impressions.
montant,
/**
* Fonction pour afficher une vente dans l'interface web.
* @returns {string} Representant un fragment HTML.
*/
show() {
const prixTxt = `${this.prix} €`;
const prixTxt = `${this.prix.toFixed(2)} €`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bien vu. Dans un futur radieux on devrait eviter l'usage des nombres basiques de javascript car ce sont des nombres en virgule flottante... Un jour il faudrait s'embêter a utiliser une bibliothèque qui permettre la gestion saine des valeurs monetaires.

const masseTxt = this.masse >= 0.00 ? ` ${this.masse} kg` : '';
return `<p>${lotTxt} ${this.quantite} * ${this.name} = ${prixTxt}${masseTxt}</p>`;
const total = `${this.montant.toFixed(2)} €`;
return `<tr>
<td> ${lotTxt} ${this.quantite} </td>
<td> ${this.name} </td>
<td> ${prixTxt}${masseTxt}</td>
<td> ${total} </td>
</tr>`;
},
};

Expand Down
Loading