public function factureReglement() { if (isset($_POST['paiementFactureDiffere'])) { $facture = Facture::find($_POST['paiementFactureDiffere']); $facture->reglee = 1; $facture->dateReglement = date("Y-m-d"); $facture->save(); $app = \Slim\Slim::getInstance(); $app->redirect($app->urlFor('accueil')); } }
public function creerFacture() { $idc = Client::where("email", $_SESSION["email"])->get()[0]; $app = \Slim\Slim::getInstance(); $facture = new \limaga\model\Facture(); if (sizeof($idc->relationPanier[0]->relationBillet) == 0 && sizeof($idc->relationPanier[0]->relationProduit) == 0 && sizeof($idc->relationPanier[0]->relationAbonnement) == 0) { $app->redirect($app->urlFor('panier')); } else { $id = 0; while ($idc->relationPanier[$id]->valide != 0) { $id++; } // calcul prix $prix = 0; foreach ($idc->relationPanier[$id]->relationProduit as $p) { $prix += $p->prix * $p->pivot["quantite"]; } $prix += sizeof($idc->relationPanier[$id]->relationBillet) * 4; foreach ($idc->relationPanier[$id]->relationAbonnement as $a) { $prix += $a->prix; } $regle = 0; $idcli = $idc->idClient; $panier = Panier::where('id_client', $idcli)->where('valide', 0)->get(); if ($_POST["paiement"] == "immediat") { $regle = 1; $panier[0]->valide = 1; $panier[0]->save(); } // moyen de paiement ?? $facture->id_client = $idc->idClient; $facture->montant = $prix; $facture->reglee = $regle; $facture->dateCreation = date("Y-m-d"); if ($regle == 1) { $facture->dateReglement = date("Y-m-d"); } $facture->id_client = $idc->idClient; $facture->id_panier = $idc->relationPanier[0]->idPanier; $facture->save(); } $app->redirect($app->urlFor('accueil')); }