• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Help function calc plugin

buc

New Member
Hi I do not understand why this function, which calculates the holidays with calc plugin only works in the insertion of the form "Calculation Ajax active" and when sending to record in the database crashes, returning blank page and not posting anything in the record. Could you help me please?
Thanks a lot.

$dal = ('{richiesta___dal}');
$al = ('{richiesta___al}');
$giorni_lavorativi = lavorativi($dal,$al,'giorni');
return "I giorni lavorativi sono: $giorni_lavorativi";

function lavorativi($dal,$al)
{
// Calcolo del giorno di Pasqua fino all'ultimo anno valido
for ($i=2015; $i<=2037; $i++) {
$pasqua = date("Y-m-d", easter_date($i));
$array_pasqua[] = $pasqua;
}

// Calcolo le rispettive pasquette
foreach($array_pasqua as $pasqua){
list ($anno,$mese,$giorno) = explode("-",$pasqua);
$pasquetta = mktime (0,0,0,date($mese),date($giorno)+1,date($anno));
$array_pasquetta[] = $pasquetta;
}

// questi giorni son sempre festivi a prescindere dall'anno
$giorniFestivi =
array(
"01-01",
"04-06",
"01-06",
"04-25",
"05-01",
"06-02",
"08-15",
"10-04",
"11-01",
"12-08",
"12-25",
"12-26",
);

$lavorativi = 0;

for($i = strtotime($dal); $i<=strtotime($al); $i = strtotime("+1 day",$i))
{
$giorno_data = date("w",$i); //verifico il giorno: da 0 (dom) a 6 (sab)
$mese_giorno = date('m-d',$i); // confronto con gg sempre festivi

// Infine verifico che il giorno non sia sabato,domenica,festivo fisso o festivo variabile (pasquetta);
if ($giorno_data !=0 && $giorno_data != 6 && !in_array($mese_giorno,$giorniFestivi) && !in_array($i,$array_pasquetta) )
{
$lavorativi++;
}

}
return $lavorativi;

}
 
changing

echo sprintf ($giorni_lavorativi);

instead of


return sprintf ($giorni_lavorativi);

displays the days on the screen but it does not record in the database
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top