55 lines
2.3 KiB
PHP
Executable File
55 lines
2.3 KiB
PHP
Executable File
<?php
|
|
$nomFicAppelant = basename(__FILE__);
|
|
include ($includePathAdmin. "/123connect.php");
|
|
|
|
// -----------------------------------------------------
|
|
// 1 - recup idClient 123clients
|
|
// -----------------------------------------------------
|
|
include ($includePathAdmin. "/req/reqRecupClient123.php");
|
|
|
|
// -----------------------------------------------------
|
|
// Recup num facture max
|
|
// -----------------------------------------------------
|
|
$reqSelect="SELECT max(idFacture) as maxf FROM `123factures` ;";
|
|
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['reqSelect' => $reqSelect], 'reqInsertFacture.php');}
|
|
$resConn='';
|
|
$resConn=$connexion->query($reqSelect);
|
|
if ($resConn) {
|
|
$tabResult=$resConn->fetch(PDO::FETCH_ASSOC);
|
|
$numFacture=$tabResult['maxf'];
|
|
}
|
|
else {
|
|
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['reqSelect' => $reqSelect], 'reqInsertFacture.php');}
|
|
}
|
|
|
|
// -----------------------------------------------------
|
|
// Nouveau num facture max = +1
|
|
// -----------------------------------------------------
|
|
$numFacture=$numFacture+1;
|
|
|
|
// -----------------------------------------------------
|
|
// Preparer le nom de fichier pdf
|
|
// -----------------------------------------------------
|
|
$fpdfFile=$_SESSION['siteNomTech']. '_facture_' .$numFacture. '.pdf';
|
|
$fpdfPath=$includePathVar. "/factures123/" .$fpdfFile;
|
|
|
|
// -----------------------------------------------------
|
|
// Insert ligne facture
|
|
// -----------------------------------------------------
|
|
$designation=$description. " - " .$comment;
|
|
if ($idClient123!='') {
|
|
$reqInsert="INSERT INTO `123factures` (idFacture, id123, lienPdf, MontantTTC, statut, description) VALUES ($numFacture, $idClient123, '" .$fpdfPath. "', $prix, 1, '" .$designation. "') ;";
|
|
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['reqInsert' => $reqInsert], 'reqInsertFacture.php');}
|
|
$resConn=$connexion->query($reqInsert);
|
|
if ($resConn) {
|
|
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['Facture insérée avec succès !' => ''], '');}
|
|
}
|
|
else {
|
|
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['Echec de l\'insertion' => ''], '');}
|
|
}
|
|
}
|
|
else {
|
|
$admMsg .= 'Client123 vide dans reqInsertFacture.php';
|
|
}
|
|
?>
|