<?php require 'fpdf/fpdf.php'; require_once 'config.php'; require_once 'global_functions.php'; $idfacture = $_GET['idfacture']; $typefacture = $_GET['type']; $table = $_GET['table']; $montant = trispace($_GET['montant']); $nofacture = $_GET['communeid']; $lastrelancedate = $_GET['relancedate']; $force = $_GET['force']; $datefacture = reverse_date_to_normal($_GET['date']); if ($lastrelancedate == '' || $force == '1') { $chrono = updatechrono($table, $idfacture); $today = date("d/m/Y"); } else { $chrono = getlastchrono($idfacture); $today = reverse_date_to_normal($lastrelancedate); } $mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB); switch ($typefacture) { case "cantine": $query = "SELECT `clients`.`clientcivilite`,`clients`.`clientnom`,`clients`.`clientprenom`,`clients`.`clientbp`,`clients`.`clientcp`,`clients`.`clientville` FROM `clients` INNER JOIN `factures_cantine` ON `factures_cantine`.`idclient` = `clients`.`clientid` WHERE `factures_cantine`.`idfacture` = '{$idfacture}'"; $result = $mysqli->query($query); $row = $result->fetch_array(MYSQLI_ASSOC); $client = $row["clientnom"] . " " . $row["clientprenom"]; $contact = "BP " . $row['clientbp'] . " - " . $row['clientcp'] . " " . $row['clientville']; switch ($row["clientcivilite"]) { case "Mr": $civilite = "Monsieur";
function getavoirlist() { $mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB); $query = "SELECT `avoirs`.`idavoir`,`avoirs`.`montant`,`avoirs`.`reste`,`avoirs`.`validation`,`avoirs`.`idfacture`,`avoirs`.`date`," . "`avoirs`.`obs`,`factures_cantine`.`datefacture`,`factures_cantine`.`datefacture`,`factures_cantine`.`montantfcp`," . "`factures_cantine`.`montanteuro`,`factures_cantine`.`duplicata` FROM `avoirs` INNER JOIN `factures_cantine` ON `avoirs`.`idfacture`=`factures_cantine`.`idfacture`" . "WHERE `avoirs`.`validation` = '0' ORDER BY date ASC, `idavoir`"; $type = "cantine"; $result = $mysqli->query($query); while ($row = $result->fetch_array(MYSQLI_ASSOC)) { if ($row["duplicata"] == '0') { $pdf = "<img src=\"img/opdf.png\" alt=\"original\" class=\"ico\">"; } else { $pdf = "<img src=\"img/dpdf.png\" alt=\"duplicata\" class=\"ico\">"; } $output .= "<tr><td>" . trispace($row["montant"]) . " FCP</td><td>" . trispace($row["reste"]) . " FCP</td>" . "<td>Facture " . $row["communeid"] . " du " . french_date($row["datefacture"]) . " montant de "; $output .= trispace($row["montantfcp"]); $output .= " FCP (soit " . $row["montanteuro"] . "€)</td><td><a href='createpdf.php?idfacture=" . $row['idfacture'] . "&type={$type}' target='_blank'>{$pdf}</a></td><td>" . french_date($row['date']) . "</td>" . "<td>" . $row['obs'] . "</td><td style=\"text-align:center\"><a href=\"javascript:validate('" . $row["idavoir"] . "',true)\">" . "<img src=\"img/checked.png\" alt=\"checked\" height=\"32\" style=\"border:0px\"></a> / <a href=\"javascript:validate('" . $row["idavoir"] . "',false)\">" . "<img src=\"img/close.png\" alt=\"close\" height=\"32\" style=\"border:0px\"></a></td></tr>"; } return $output; }
function buildFacturesEnAttente($idclient) { $mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB); $query = "SELECT * FROM `" . DB . "`.`factures_amarrage` WHERE `idclient`={$idclient} AND `validation`=0"; $result = $mysqli->query($query); if ($mysqli->affected_rows > 0) { $list = "<br><b>Factures provisoires en attente de validation -- actuellement imprimable en tant que devis</b>"; while ($row = $result->fetch_array(MYSQLI_ASSOC)) { $list .= "<br/><a href='createpdf.php?idfacture=" . $row['idfacture'] . "&type=amarrage' target='_blank'>Devis " . $row['communeid'] . " du " . $row['datefacture'] . " montant de "; $list .= trispace($row['montantfcp']); $list .= " FCP (soit " . $row['montanteuro'] . " euros)</a>"; } } else { $list = ""; } $mysqli->close(); return $list; }
function getInfo() { $id = $_GET['id']; $type = $_GET['type']; $mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB); switch ($type) { case "repas": $output[0] = "<b>Encaissement au comptant (Ticket Repas)</b><br/>"; $output[1] = strtoupper($type); break; case "cantine": $query = "SELECT `datefacture`,`communeid`,`montantfcp`,`montanteuro`,`restearegler` FROM `" . DB . "`.`factures_cantine` WHERE `idfacture` = {$id}"; $result = $mysqli->query($query); $row = $result->fetch_array(MYSQLI_ASSOC); $output[0] = "<b>Facture {$type} " . $row['communeid'] . " du " . standarddateformat($row['datefacture']) . " montant " . trispace($row['montantfcp']) . "FCP (" . $row['montanteuro'] . "€)</b><br/>" . "Reste à régler " . trispace($row['restearegler']) . " FCP<input type='hidden' id='montantmax' value='" . $row['restearegler'] . "'/><input type='hidden' id='montanttotal' value='" . $row['montantfcp'] . "'/>"; $output[1] = strtoupper($type); break; case "etal": $query = "SELECT `datefacture`,`communeid`,`montantfcp`,`montanteuro`,`restearegler` FROM `" . DB . "`.`factures_etal` WHERE `idfacture` = {$id}"; $result = $mysqli->query($query); $row = $result->fetch_array(MYSQLI_ASSOC); $output[0] = "<b>Facture Place et Etal " . $row['communeid'] . " du " . standarddateformat($row['datefacture']) . " montant " . trispace($row['montantfcp']) . "FCP (" . $row['montanteuro'] . "€)</b><br/>" . "Reste à régler " . trispace($row['restearegler']) . " FCP<input type='hidden' id='montantmax' value='" . $row['restearegler'] . "'/><input type='hidden' id='montanttotal' value='" . $row['montantfcp'] . "'/>"; $output[1] = "PLACE ET ETAL"; break; case "amarrage": $query = "SELECT `datefacture`,`communeid`,`montantfcp`,`montanteuro`,`restearegler` FROM `" . DB . "`.`factures_amarrage` WHERE `idfacture` = {$id}"; $result = $mysqli->query($query); $row = $result->fetch_array(MYSQLI_ASSOC); $output[0] = "<b>Facture Amarrage " . $row['communeid'] . " du " . standarddateformat($row['datefacture']) . " montant " . trispace($row['montantfcp']) . "FCP (" . $row['montanteuro'] . "€)</b><br/>" . "Reste à régler " . trispace($row['restearegler']) . " FCP<input type='hidden' id='montantmax' value='" . $row['restearegler'] . "'/><input type='hidden' id='montanttotal' value='" . $row['montantfcp'] . "'/>"; $output[1] = "AMARRAGE"; break; } $mysqli->close(); return $output; }
function genpdf($idfacture, $idpaiement, $date, $payeur, $type, $mode, $montant, $initiales, $no_cheque, $organisme, $obs) { $xreg = 1.5; $yreg = 3.5; $pdf = new FPDF('P', 'mm', 'A4'); $pdf->AddPage(); //logo $pdf->Image('img/logo.jpg', 10 + $xreg, 14 + $yreg, 12, 10, 'jpg'); $pdf->SetLineWidth(0.4); $pdf->Rect(4 + $xreg, 7 + $yreg, 196, 30); //rectangle global $pdf->Line(4 + $xreg, 13 + $yreg, 200 + $xreg, 13 + $yreg); //1ere barre horizontale $pdf->Line(27 + $xreg, 7 + $yreg, 27 + $xreg, 37 + $yreg); //1ere barre verticale $pdf->Line(77 + $xreg, 7 + $yreg, 77 + $xreg, 37 + $yreg); //2nd barre verticale $pdf->Line(127 + $xreg, 7 + $yreg, 127 + $xreg, 37 + $yreg); //3eme barre verticale $pdf->Line(152 + $xreg, 7 + $yreg, 152 + $xreg, 37 + $yreg); //4eme barre verticale $pdf->Line(177 + $xreg, 7 + $yreg, 177 + $xreg, 37 + $yreg); //5eme barre verticale $pdf->SetLineWidth(0.2); $pdf->Line(27 + $xreg, 21 + $yreg, 200 + $xreg, 21 + $yreg); //1ere barre fine horizontale $pdf->Line(4 + $xreg, 31 + $yreg, 200 + $xreg, 31 + $yreg); //2nd barre fine horizontale $pdf->SetFont('Arial', '', 8); $pdf->SetXY(4 + $xreg, 7 + $yreg); $pdf->Cell(23, 7, utf8_decode('DATE'), 0, 1, 'C'); $pdf->SetXY(27 + $xreg, 7 + $yreg); $pdf->Cell(50, 7, utf8_decode('NOM de la partie versante'), 0, 1, 'C'); $pdf->SetXY(27 + $xreg, 13 + $yreg); $pdf->Cell(50, 7, utf8_decode('Reçu de M.'), 0, 1, ''); $pdf->SetXY(77 + $xreg, 7 + $yreg); $pdf->Cell(50, 7, utf8_decode('DESIGNATION DES PRODUITS'), 0, 1, 'C'); $pdf->SetXY(127 + $xreg, 7 + $yreg); $pdf->Cell(25, 3.5, utf8_decode('VERSEMENT'), 0, 1, 'C'); $pdf->SetXY(127 + $xreg, 9.5 + $yreg); $pdf->Cell(25, 3.5, utf8_decode('en numéraire'), 0, 1, 'C'); $pdf->SetXY(152 + $xreg, 7 + $yreg); $pdf->Cell(25, 7, utf8_decode('CHEQUES'), 0, 1, 'C'); $pdf->SetXY(177 + $xreg, 7 + $yreg); $pdf->Cell(25, 7, utf8_decode('DIVERS'), 0, 1, 'C'); //data $pdf->SetXY(4 + $xreg, 25 + $yreg); $pdf->Cell(23, 7, "No. " . $idpaiement, 0, 1, 'C'); $pdf->SetXY(4 + $xreg, 31 + $yreg); $pdf->Cell(23, 7, standarddateformat($date), 0, 1, 'C'); $pdf->SetXY(27 + $xreg, 31 + $yreg); $pdf->Cell(50, 7, utf8_decode($obs), 0, 1, ''); $pdf->SetXY(27 + $xreg, 21 + $yreg); $pdf->Cell(50, 10, strtoupper(utf8_decode($payeur)), 0, 1, 'C'); switch ($mode) { case 'num': $pdf->SetXY(125 + $xreg + $xreg, 21 + $yreg); break; case 'chq': $pdf->SetXY(150 + $xreg + $xreg, 19 + $yreg); break; default: $pdf->SetXY(175 + $xreg + $xreg, 21 + $yreg); break; } $pdf->Cell(25, 10, utf8_decode(trispace($montant) . ' FCP'), 0, 1, 'C'); $pdf->SetXY(150 + $xreg + $xreg, 23 + $yreg); $pdf->Cell(25, 10, utf8_decode($organisme . ' ' . $no_cheque), 0, 1, 'C'); $pdf->SetXY(77 + $xreg + $xreg, 13 + $yreg); $pdf->Cell(50, 10, utf8_decode('Facture n° ' . $idfacture), 0, 1, 'C'); $pdf->SetXY(77 + $xreg + $xreg, 21 + $yreg); $pdf->Cell(50, 10, utf8_decode($type), 0, 1, 'C'); $pdf->SetXY(77 + $xreg + $xreg, 29 + $yreg); $pdf->Cell(50, 10, utf8_decode('Receveur ' . $initiales), 0, 1, 'C'); $pdf->Output(); }
function buildFacturesEnCoursTable($id, $ar_tables) { //print_r($ar_tables); $mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB); $output = "<table class=\"tblform\"><tbody><tr><th>Type de Facture</th><th>Facture</th><th>Status</th><th>Commentaire</th></tr></tbody>"; foreach ($ar_tables as &$val) { $query = "SELECT * FROM `" . $val['table'] . "` WHERE `idclient` = {$id} ORDER BY datefacture DESC, idfacture DESC limit 30"; $result = $mysqli->query($query); while ($row = $result->fetch_array(MYSQLI_ASSOC)) { $comment = str_replace(" ; ", "<br/>", $row["comment"]); if ($row["validation"] == 0) { $status = "En cours de validation"; $reject = ""; } else { if ($row["acceptation"] == 0) { $status = "Refusée"; $reject = "reject"; } else { $status = "Validée"; $reject = ""; } } $output .= "<tbody class=\"{$reject}\"><tr><td>" . $val['title'] . "</td><td><a href=\"createpdf.php?idfacture=" . $row['idfacture'] . "&type=" . $val['link'] . "\" target=\"_blank\">Facture du " . $row["datefacture"] . " montant de "; $output .= trispace($row["montantfcp"]); $output .= " FCP (soit " . $row["montanteuro"] . " €)</a></td><td>{$status}</td><td>{$comment}</td></tr></tbody>"; } } $output .= "</table>"; $mysqli->close(); return $output; }
function getcantinelist($client, $range) { $mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB); $query = "SELECT * FROM `factures_cantine` INNER JOIN `clients` ON `factures_cantine`.`idclient` = `clients`.`clientid` WHERE `factures_cantine`.`validation` = '1' AND `acceptation` = '1' AND `reglement` = '0' AND `bourse` = '0' {$range}{$client} ORDER BY `datefacture` ASC"; $result = $mysqli->query($query); while ($row = $result->fetch_array(MYSQLI_ASSOC)) { if ($row["duplicata"] == '0') { $pdf = "<img src=\"img/opdf.png\" alt=\"original\" class=\"ico\">"; } else { $pdf = "<img src=\"img/dpdf.png\" alt=\"duplicata\" class=\"ico\">"; } $datef = $row["datefacture"]; $dayslate = strtotime("now") - strtotime($datef); $dayslate = floor($dayslate / 86400); $type = 'cantine'; $enfant_prenom = "<br/>" . getEnfantPrenom($row['idfacture']); $relance_date = getRelance($row['idfacture']); if (isset($relance_date)) { $relance_date_fr = french_date($relance_date); $titlerelance = "Dernière relance le " . $relance_date_fr; } else { $relance_date_fr = ""; $titlerelance = ""; } $output .= "<tr><td>{$type}{$enfant_prenom}</td><td><a href='clients.php?edit=" . $row["clientid"] . "&hideerrors=1'>" . $row["clientcivilite"] . " " . strtoupper(htmlentities($row["clientnom"])) . " " . strtoupper(htmlentities($row["clientprenom"])) . " " . strtoupper(htmlentities($row["clientprenom2"])) . "</a></td>" . "<td>Facture " . $row["communeid"] . " du " . french_date($row["datefacture"]) . " montant de "; $output .= trispace($row["montantfcp"]); $output .= " FCP (soit " . $row["montanteuro"] . "€)</td><td><a href='createpdf.php?idfacture=" . $row['idfacture'] . "&type={$type}' target='_blank'>{$pdf}</a></td>" . "<td class='center'>{$dayslate} jours</td><td>{$relance_date_fr}<br/><a href='javascript:relance_warning(\"{$relance_date_fr}\",\"create_relance.php?idfacture=" . $row['idfacture'] . "&type={$type}&table=factures_cantine&montant=" . $row["montantfcp"] . "&communeid=" . $row["communeid"] . "&date=" . $row["datefacture"] . "&relancedate={$relance_date}\");'><img src='img/gmail.png' title='{$titlerelance}'/></a></td></tr>"; $ar_ids[] .= $row["idfacture"]; } $mysqli->close(); //return $output; //print_r($ar_ids); return array($output, $ar_ids); }
function getcantinelist($client) { $mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB); $query = "SELECT * FROM `" . DB . "`.`factures_cantine` INNER JOIN `clients` ON `factures_cantine`.`idclient` = `clients`.`clientid` WHERE `factures_cantine`.`validation` = '1' AND `acceptation` = '1' AND `reglement` = '0'{$client}"; $result = $mysqli->query($query); while ($row = $result->fetch_array(MYSQLI_ASSOC)) { if ($row["duplicata"] == '0') { $pdf = "<img src=\"img/opdf.png\" alt=\"original\" class=\"ico\">"; } else { $pdf = "<img src=\"img/dpdf.png\" alt=\"duplicata\" class=\"ico\">"; } $type = 'cantine'; $enfant_prenom = "<br/>" . getEnfantPrenom($row['idfacture']); $output .= "<tr><td>{$type}{$enfant_prenom}</td><td><a href='clients.php?edit=" . $row["clientid"] . "&hideerrors=1'>" . $row["clientcivilite"] . " " . strtoupper(htmlentities($row["clientnom"])) . " " . strtoupper(htmlentities($row["clientprenom"])) . " " . strtoupper(htmlentities($row["clientprenom2"])) . "</td>" . "<td>Facture " . $row["communeid"] . " du " . french_date($row["datefacture"]) . " montant de "; $output .= trispace($row["montantfcp"]); $output .= " FCP (soit " . $row["montanteuro"] . "€)</a></td><td><a href='createpdf.php?idfacture=" . $row['idfacture'] . "&type={$type}' target='_blank'>{$pdf}</a></td>" . "<td class='center'><a href=\"javascript:devalidate('{$type}','" . $row["idfacture"] . "')\"><img src=\"img/close.png\" alt=\"close\" height=\"32\" style=\"border:0px\"></a></td></tr>"; } return $output; }