This commit is contained in:
2025-09-30 21:24:37 +02:00
parent d603fb452a
commit b7b9cebacb
258 changed files with 416 additions and 601 deletions

View File

@@ -0,0 +1,116 @@
{% extends 'base.html.twig' %}
{% block body %}
<h1 class="page-header">
Récupération Commande Client Dolibarr
</h1>
<a class="btn btn-secondary" href={{ path('app_offer') }}>Annuler</a>
<br><br>
<div class="card">
<div class="card-header">
<i class="fa fa-pencil-alt fa-fw"></i> Informations
</div>
<div class="card-body">
<div class="form-group ">
<label class="control-label required" for="id">ID Proposition<span class="mandatory">*</span></label>
<input type="text" id="ref" name="ref" required="required" class=" form-control" value="CO2311-0222">
<button id="search" class="btn btn-success mt-1" style="width:100%">Rechercher</span>
</div>
</div>
</div>
<div id="card-propal" class="card mt-3" style="display:none">
<div class="card-header">
<i class="fa fa-pencil-alt fa-fw"></i> Lignes propositions
</div>
<div class="card-body" id="propal">
</div>
</div>
<div id="card-offer" class="card mt-3 mb-3" style="display:none">
<div class="card-header">
<i class="fa fa-pencil-alt fa-fw"></i> Importer dans Schedule
</div>
<div class="card-body" id="propal">
{{ form_start(form) }}
{{ form_row(form.name) }}
{{ form_row(form.project) }}
{{ form_widget(form.submit) }}
{{ form_end(form) }}
</div>
</div>
{% endblock %}
{% block localjavascript %}
$("#search").click(function() {
console.log("search propositions = "+$("#ref").val());
$.ajax({
type: "POST",
data: {
ref: $("#ref").val(),
},
url: "{{ path('app_offer_getdolibarr') }}",
success: function (datas) {
console.log(datas);
console.log("-----------");
if(datas.error||Object.keys(datas).length === 0) {
$("#propal").html("");
$("#card-propal").hide();
$("#card-offer").hide();
}
else {
html ="<h3>"+$("#ref").val()+"</h3>";
if(datas.note_public) html+="<strong>Note public</strong><br><small style='display: block;line-height: 14px;'>"+datas.note_public.replace(/(\r\n|\r|\n)/g, '<br>')+"</small><br><br>";
if(datas.note_private) html+="<strong>Note privée</strong><br><small style='display: block;line-height: 14px;'>"+datas.note_private.replace(/(\r\n|\r|\n)/g, '<br>')+"</small><br><br>";
tbtask={};
datas.lines.forEach(function(line){
console.log(line);
if(!tbtask[line.product_ref]) tbtask[line.product_ref]={idoffer:"", idline: "", ref: "", label: "", qty: 0, price:0 };
tbtask[line.product_ref]["idoffer"]=$("#ref").val();
tbtask[line.product_ref]["idline"]=line.id;
tbtask[line.product_ref]["ref"]=line.product_ref;
tbtask[line.product_ref]["label"]=line.product_label;
tbtask[line.product_ref]["qty"]=parseInt(line.qty)+tbtask[line.product_ref]["qty"];
tbtask[line.product_ref]["price"]=parseInt(line.price);
});
html+="<table style='width:100%;'>";
html+="<thead><tr>";
html+="<th>Ref</th>";
html+="<th>Designation</th>";
html+="<th>Qte</th>";
html+="<th>PU</th>";
html+="<th>Total</th>";
html+="</tr></thead>";
Object.values(tbtask).forEach(task => {
html+="<tr>";
html+="<td>"+task.ref+"</td>";
html+="<td>"+task.label+"</td>";
html+="<td>"+task.qty+"</td>";
html+="<td>"+task.price+"</td>";
html+="<td>"+(task.qty*task.price)+"</td>";
html+="</tr>";
});
html+="</table>";
$("#propal").html(html);
$("#card-propal").show();
$("#card-offer").show();
$("#offerdolibarr_tasks").val(JSON.stringify(tbtask));
}
}
});
});
{% endblock %}

78
templates/Offer/edit.html.twig Executable file
View File

@@ -0,0 +1,78 @@
{% extends 'base.html.twig' %}
{% block body %}
{{ form_start(form) }}
<h1 class="page-header">
{% if fgprint is defined and fgprint %}
COMMANDE
{% elseif mode=="update" %}
Modification COMMANDE
{% elseif mode=="submit" %}
Création COMMANDE
{% endif %}
</h1>
{{ form_widget(form.submit) }}
<a class="btn btn-secondary" href={{ path('app_offer') }}>Annuler</a>
{% if mode=="update" %}
<a href="{{ path('app_offer_delete',{'id':offer.id}) }}"
class="btn btn-danger float-right"
data-method="delete"
data-confirm="Êtes-vous sûr de vouloir supprimer cet entregistrement ?">
Supprimer
</a>
{% endif %}
<br><br>
{% if app.session.flashbag.has('error') %}
<div class='alert alert-danger' style='margin: 5px 0px'>
<strong>Erreur</strong><br>
{% for flashMessage in app.session.flashbag.get('error') %}
{{ flashMessage }}<br>
{% endfor %}
</div>
{% endif %}
{% if app.session.flashbag.has('notice') %}
<div class='alert alert-info' style='margin: 5px 0px'>
<strong>Information</strong><br>
{% for flashMessage in app.session.flashbag.get('notice') %}
{{ flashMessage }}<br>
{% endfor %}
</div>
{% endif %}
<div class="card">
<div class="card-header">
<i class="fa fa-pencil-alt fa-fw"></i> Informations
</div>
<div class="card-body">
{{ form_row(form.name) }}
{{ form_row(form.ref) }}
{{ form_row(form.service) }}
{{ form_row(form.project) }}
{{ form_row(form.quantity) }}
{{ form_row(form.pu) }}
{{ form_row(form.validate) }}
{{ form_row(form.cost) }}
{{ form_row(form.active) }}
</div>
</div>
{{ form_end(form) }}
{% endblock %}
{% block localjavascript %}
$(document).ready(function() {
$("#offer_name").focus();
});
function myprint() {
href=document.location.href;
document.location.href=href+"?fgprint=true";
}
{% endblock %}

View File

@@ -0,0 +1,187 @@
{% extends "base.html.twig" %}
{% block localstyle %}
td {
padding:5px !important;
}
{% if fgprint is defined and fgprint %}
table { font-size:10px;}
th,td {
border: 1px solid #37474F;
}
thead {
display: table-header-group;
}
tr { page-break-inside: avoid; }
{%endif%}
{% endblock %}
{% block body %}
<h1 class="page-header">
COMMANDES {% if app.session.get('viewservice') %}PAR ACTVITE{%else%}PAR DOMAINE{%endif%}
</h1>
<a class="btn btn-success" href={{ path('app_offer_submit') }}>Ajouter</a>
{% if doliactive == "true" %}
<a class="btn btn-success" href={{ path('app_offer_dolibarr') }}>Récupérer les commandes de Dolibarr</a>
{% endif %}
<div class="custom-control custom-switch float-right">
<input type="checkbox" class="custom-control-input" id="switchactiveproject" {% if app.session.get('activeproject') %} checked {% endif %}>
<label class="custom-control-label" for="switchactiveproject">Projet Actif</label>
</div>
<div class="custom-control custom-switch float-right" style="margin-right:10px">
<input type="checkbox" class="custom-control-input" id="switchactiveoffer" {% if app.session.get('activeoffer') %} checked {% endif %}>
<label class="custom-control-label" for="switchactiveoffer">Proposition Active</label>
</div>
<div class="custom-control custom-switch float-right mr-3">
<input type="checkbox" class="custom-control-input" id="switchservice" {% if app.session.get('viewservice') %} checked {% endif %}>
{% if app.session.get('viewservice') %}
<label class="custom-control-label" for="switchservice">Vue par Activité</label>
{% else %}
<label class="custom-control-label" for="switchservice">Vue par Domaine</label>
{% endif %}
</div>
<p></p>
{% if app.session.get('viewservice') %}
{% set loop01s=services %}
{% else %}
{% set loop01s=domaines %}
{% endif %}
{%for loop01 in loop01s %}
{% if not loop01.projects is empty %}
{% set haveoffer=false %}
{% set haveproject=false %}
{% for offer in loop01.offers %}
{% if app.session.get('activeoffer')==offer.active and app.session.get('activeproject')==offer.project.active and (app.session.get('idproject')=="all" or app.session.get('idproject')==offer.project.id) %}
{% set haveoffer=true %}
{% set haveproject=true %}
{% endif %}
{% endfor %}
{% if haveoffer and haveproject %}
<div class="card">
<div class="card-header">
<i class="fa fa-table fa-fw"></i> {{ loop01.name }}
</div>
<div class="card-body">
<div class="dataTable_wrapper">
<table class="table table-striped table-bordered table-hover small" id="dataTables" style="width:100%">
<thead>
<tr>
<th width="70px" class="no-sort no-print">Action</th>
<th width="200px">Client</th>
<th>Projet</th>
<th width="100px">Proposition</th>
<th width="100px">Ref</th>
<th width="70px" class="text-center no-string">Validé hors</th>
<th width="70px" class="text-center no-string">Frais</th>
<th width="70px" class="text-center no-string">Qt</th>
<th width="70px" class="text-center no-string">PU</th>
<th width="100px" class="text-center no-string">Total</th>
</tr>
</thead>
<tbody>
{% if loop01.offers is defined %}
{% for offer in loop01.offers %}
{% if app.session.get('activeoffer')==offer.active and app.session.get('activeproject')==offer.project.active and (app.session.get('idproject')=="all" or app.session.get('idproject')==offer.project.id) %}
<tr>
<td class="no-print">
<a href="{{path("app_offer_update",{id:offer.id})}}"><i class="fa fa-file"></i></a>
</td>
<td>{{offer.project.customer.name}}</td>
<td>{{offer.project.name}}</td>
<td>{{offer.name}}</td>
{% if offer.iddolibarr %}
<td><a href="{{doliUri}}/commande/card.php?ref={{offer.ref}}" target="_blank">{{offer.ref}}</td>
{% else %}
<td>{{offer.ref}}</td>
{% endif %}
<td class="text-right">{{offer.validate|number_format(2, '.', ' ')}}</td>
<td class="text-right">{{offer.cost|number_format(2, '.', ' ')}}</td>
<td class="text-right">{{offer.quantity|number_format(2, '.', ' ')}}</td>
<td class="text-right">{{offer.pu|number_format(2, '.', ' ')}}</td>
<td class="text-right">{{offer.total|number_format(2, '.', ' ')}}</td>
</tr>
{%endif%}
{% endfor %}
{% else %}
{% for project in loop01.projects %}
{% for offer in project.offers %}
{% if app.session.get('activeoffer')==offer.active and app.session.get('activeproject')==offer.project.active and (app.session.get('idproject')=="all" or app.session.get('idproject')==offer.project.id) %}
<tr>
<td class="no-print">
<a href="{{path("app_offer_update",{id:offer.id})}}"><i class="fa fa-file"></i></a>
</td>
<td>{{offer.project.customer.name}}</td>
<td>{{offer.project.name}}</td>
<td>{{offer.name}}</td>
{% if offer.iddolibarr %}
<td><a href="{{doliUri}}/commande/card.php?ref={{offer.ref}}" target="_blank">{{offer.ref}}</td>
{% else %}
<td>{{offer.ref}}</td>
{% endif %}
<td class="text-right">{{offer.validate|number_format(2, '.', ' ')}}</td>
<td class="text-right">{{offer.cost|number_format(2, '.', ' ')}}</td>
<td class="text-right">{{offer.quantity|number_format(2, '.', ' ')}}</td>
<td class="text-right">{{offer.pu|number_format(2, '.', ' ')}}</td>
<td class="text-right">{{offer.total|number_format(2, '.', ' ')}}</td>
</tr>
{%endif%}
{% endfor %}
{% endfor %}
{% endif %}
</tbody>
</table>
</div>
</div>
</div>
<br>
{% endif %}
{% endif %}
{% endfor %}
{% endblock %}
{% block localjavascript %}
$(document).ready(function() {
{% if not fgprint is defined or not fgprint %}
$('.table ').DataTable({
columnDefs: [ { "targets": "no-sort", "orderable": false }, { "targets": "no-string", "type" : "num" } ],
responsive: true,
iDisplayLength: 100,
order: [[ 1, "asc" ]]
});
{%else%}
$('#dataTables').removeClass("table table-striped table-bordered table-hover small dataTable no-footer");
{% endif %}
});
function myprint() {
href=document.location.href;
document.location.href=href+"?fgprint=true";
}
$('#switchactiveproject').change(function() {
window.location="{{ path('app_offer_activeproject' )}}";
});
$('#switchactiveoffer').change(function() {
window.location="{{ path('app_offer_activeoffer' )}}";
});
$('#switchservice').change(function() {
window.location="{{ path('app_offer_viewservice' )}}";
});
{% endblock %}