1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-08 06:31:20 +01:00
openstamanager/plugins/pianificazione_fatturazione/ajax_cadenza.php

129 lines
3.9 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;
2024-03-05 16:01:45 +01:00
use Models\Module;
2024-03-22 15:52:24 +01:00
use Modules\Contratti\Contratto;
2021-02-18 09:57:35 +01:00
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">';
2024-01-15 15:30:45 +01:00
$data_corrente = $data_inizio->startOfMonth();
$data_conclusione = $contratto->data_conclusione;
$count = 0;
2021-02-18 09:57:35 +01:00
2024-01-15 15:30:45 +01:00
while ($data_corrente->lessThanOrEqualTo($data_conclusione)) {
$data = $data_corrente->endOfMonth()->format('Y-m-d');
$data_fatturazione = ($data_fatturazione ?: date('Y-m', strtotime($data)));
unset($checked);
2021-02-18 09:57:35 +01:00
2024-06-11 16:58:27 +02:00
if ($id_module == Module::where('name', 'Contratti')->first()->id) {
2024-05-23 11:36:25 +02:00
if ($data == date('Y-m-t', strtotime((string) $timeing, strtotime((string) $data_fatturazione))) || $data_fatturazione == date('Y-m', strtotime($data_corrente))) {
2024-01-15 15:30:45 +01:00
$checked = 'checked';
$data_fatturazione = date('Y-m', strtotime($data));
2021-02-18 09:57:35 +01:00
}
2024-01-15 15:30:45 +01:00
}
2021-02-18 09:57:35 +01:00
2024-01-15 15:30:45 +01:00
echo '
2021-02-18 09:57:35 +01:00
<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>';
2024-01-15 15:30:45 +01:00
$data_corrente = $data_corrente->addDay();
++$count;
}
2021-02-18 09:57:35 +01:00
2024-01-15 15:30:45 +01:00
echo '
2021-02-18 09:57:35 +01:00
</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>';