1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-28 00:30:45 +01:00
openstamanager/plugins/pianificazione_fatturazione/ajax_cadenza.php

128 lines
4.0 KiB
PHP
Raw Normal View History

2021-02-18 09:57:35 +01:00
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
2021-02-18 18:53:28 +01:00
* Copyright (C) DevCode s.r.l.
2021-02-18 09:57:35 +01:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use Carbon\Carbon;
use Modules\Contratti\Contratto;
include_once __DIR__.'/../../core.php';
$contratto = Contratto::find($id_record);
2021-02-18 18:48:44 +01:00
if (get('scadenza') == 'Mensile') {
2021-02-18 09:57:35 +01:00
$timeing = '+1 month';
}
2021-02-18 18:48:44 +01:00
if (get('scadenza') == 'Bimestrale') {
2021-02-18 09:57:35 +01:00
$timeing = '+2 month';
}
2021-02-18 18:48:44 +01:00
if (get('scadenza') == 'Trimestrale') {
2021-02-18 09:57:35 +01:00
$timeing = '+3 month';
}
2021-02-18 18:48:44 +01:00
if (get('scadenza') == 'Quadrimestrale') {
2021-02-18 09:57:35 +01:00
$timeing = '+4 month';
}
2021-02-18 18:48:44 +01:00
if (get('scadenza') == 'Semestrale') {
2021-02-18 09:57:35 +01:00
$timeing = '+6 month';
}
2021-02-18 18:48:44 +01:00
if (get('scadenza') == 'Annuale') {
2021-02-18 09:57:35 +01:00
$timeing = '+12 month';
}
$data_inizio = new Carbon(get('data_inizio'));
echo '
<div class="row" id="ajax_cadenza">';
$data_corrente = $data_inizio->startOfMonth();
$data_conclusione = $contratto->data_conclusione;
$count = 0;
while ($data_corrente->lessThanOrEqualTo($data_conclusione)) {
$data = $data_corrente->endOfMonth()->format('Y-m-d');
2021-02-18 18:48:44 +01:00
$data_fatturazione = ($data_fatturazione ?: date('Y-m', strtotime($data)));
2021-02-18 09:57:35 +01:00
unset($checked);
2021-02-18 18:48:44 +01:00
if ($id_module == Modules::get('Contratti')['id']) {
if ($data == date('Y-m-t', strtotime($timeing, strtotime($data_fatturazione))) || $data_fatturazione == date('Y-m', strtotime($data_corrente))) {
2021-02-18 09:57:35 +01:00
$checked = 'checked';
2021-02-18 18:48:44 +01:00
$data_fatturazione = date('Y-m', strtotime($data));
2021-02-18 09:57:35 +01:00
}
}
echo '
<div class="col-md-3">
<label for="m_'.$count.'">
<input type="checkbox" onchange="controlloProcedi();" class="unblockable check_periodo" id="m_'.$count.'" name="selezione_periodo['.$count.']" '.$checked.' />
2022-12-02 17:17:04 +01:00
'.ucfirst($data_corrente->isoFormat('MMMM YY')).'
2021-02-18 09:57:35 +01:00
</label>
<input type="hidden" name="periodo['.$count.']" value="'.$data.'">
</div>';
$data_corrente = $data_corrente->addDay();
++$count;
}
echo '
</div>
<script>
$(document).ready(function(){
var check = 0;
$("#periodi input").each(function (){
if( $(this).is(":checked") ){
check = check + 1;
}
});
$("#total_check").html("Rate: " + check).trigger("change");
$(".num_rate").html(check).trigger("change");
var qta_disponibili = 0;
$(".alert_rate").each(function (){
qta_disponibili = parseFloat($(this).find(".qta_disponibili").text());
if (check > qta_disponibili ){
$(this).removeClass("hide");
}else{
$(this).addClass("hide");
}
});
2021-02-18 09:57:35 +01:00
});
$("#periodi input").change(function(){
var check = 0;
$("#periodi input").each(function (){
if( $(this).is(":checked") ){
check = check + 1;
}
});
$("#total_check").html("Rate: " + check).trigger("change");
$(".num_rate").html(check).trigger("change");
var qta_disponibili = 0;
$(".alert_rate").each(function (){
qta_disponibili = parseFloat($(this).find(".qta_disponibili").text());
if (check > qta_disponibili ){
$(this).removeClass("hide");
}else{
$(this).addClass("hide");
}
});
});
2021-02-18 18:48:44 +01:00
</script>';