<?php
namespace App\Repository\stock;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use App\Entity\stock\Commande;
use App\ControllerModel\user\paramUtilTrait;
use Doctrine\ORM\RepositoryRepository;
use DateInterval;
/**
* CommandeRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class CommandeRepository extends ServiceEntityRepository
{
use paramUtilTrait;
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Commande::class);
}
public function getInformationCommande($code) {
$qb = $this->createQueryBuilder('c')
->where('c.codeCommande = \'' . $code . '\'');
return $qb->getQuery()->getResult();
}
public function getClientCommande($id) {
$query = $this->_em->createQuery(
'SELECT c,a
FROM App\Entity\stock\Commande c INNER JOIN c.abonne a
WHERE a.id = :id'
)->setParameter('id', $id);
return $query->getResult();
}
public function getUtilisateurCommande($id) {
$query = $this->_em->createQuery(
'SELECT c
FROM App\Entity\stock\Commande c INNER JOIN c.fournisseur f
WHERE f.id = :id ORDER BY c.id DESC'
)->setParameters(array('id' => $id));
return $query->getResult();
}
public function getUtilisateurCommandeRecherche($id, $datefin, $datedeb) {
$param = array();
$datedebarray = array();
$datefinarray = array();
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = "01/01/2014";//$premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}
//traitement des tableaux
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
$sql = "SELECT c
FROM App\Entity\stock\Commande c
INNER JOIN c.fournisseur f ";
$sql .= " WHERE c.annule != 1 and 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.dateCommande >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.dateCommande <= " . " '" . $paramfin . "' " : $sql .= '';
( $id == '0' || $id == '') ? $sql .= '' : $sql .= ' AND f.id =:id ';
//var_dump($sql);exit;
/** Fin critère recherche * */
$sql .= ' ORDER BY c.id DESC ';
/** debut parametres * */
( $id == '0' || $id == '') ? $sql .= '' : $param['id'] = $id;
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
return $query->getResult();
}
public function getUtilisateurCommandeParEtat($id, $etat = 1) {
$query = $this->_em->createQuery(
'SELECT c
FROM App\Entity\stock\Commande c INNER JOIN c.fournisseur f
WHERE c.annule != 1 and f.id = :id and c.etatCommande =:etatCommande ORDER BY c.id DESC'
)->setParameters(array('id' => $id, 'etatCommande' => $etat));
return $query->getResult();
}
public function getLigneCommande($id) {
$query = $this->_em->createQuery(
'SELECT l,c
FROM App\Entity\stock\LigneCommande l INNER JOIN l.commande c
WHERE c.id = :id'
)->setParameter('id', $id);
return $query->getResult();
}
public function getListeCommandeParType() {
$query = $this->_em->createQuery(
'SELECT c
FROM App\Entity\stock\Commande c
WHERE c.annule != 1 and 1=1 ORDER BY c.id DESC'
);
return $query->getResult();
}
public function getListeCommandeParTypeLimit($type, $etat = 1) {
$query = $this->_em->createQuery(
'SELECT c
FROM App\Entity\stock\Commande c
WHERE c.annule != 1 and c.typeCommande = :typeCommande ORDER BY c.id DESC '
)->setParameters(array('typeCommande' => $type));
return $query->getResult();
}
public function getOneCommande($id) {
$qb = $this->createQueryBuilder('c')
->select('c')
->where('c.id = ' . $id);
return $qb->getQuery()->getResult();
}
public function getDerniereOneCommande() {
$qb = $this->createQueryBuilder('c')
->select('c')
->where('c.typeCommande =1 ')
->orderBy('c.id', 'DESC');
// ->addCriteria('LIMIT', 1);
return $qb->getQuery()->getResult();
// var_dump($qb->getQuery()->getResult());exit;
}
public function getListeCommandeByCategorie($idCommande, $idCategorie) {
$sql = "SELECT li
FROM App\Entity\stock\LigneCommande li ";
$sql .= " INNER JOIN li.commande c ";
$sql .= " INNER JOIN li.produit p ";
$sql .= " INNER JOIN p.categorie cg ";
$sql .= " WHERE c.annule != 1 and 1=1 ";
( $idCommande == '0' || $idCommande == '') ? $sql .= '' : $sql .= ' AND c.id = :commande';
( $idCategorie == '0' || $idCategorie == '') ? $sql .= '' : $sql .= ' AND cg.id = :idCategorie';
//$sql .= ' ORDER BY i.dateLivraison DESC ';
/** Fin critère recherche * */
/** debut parametres * */
( $idCommande == '0' || $idCommande == '') ? $sql .= '' : $param['commande'] = $idCommande;
( $idCategorie == '0' || $idCategorie == '') ? $sql .= '' : $param['idCategorie'] = $idCategorie;
$queryLivr = $this->_em->createQuery($sql);
$queryLivr->setParameters($param);
return $queryLivr->getResult();
}
public function getListeRechercheCommande($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $prod = 0,$type=0,$typeLimite = 0, $nbParPage = 20, $pageActuelle = 1,$abonneId=0,$retrait=0, $clientId = 0, $siCredit=0,$surfaceId=0, $action=0) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000000;
/*if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}*/
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y 00:00:00"); //$dateJour->format("d/m/Y 00:00:00");//
$datefin = $premierDate->add(new DateInterval('P1M'))->format("d/m/Y 00:00:00"); //$dateJour->format("d/m/Y 23:59:59");//
//$datefin = $dateMoi->format("d/m/Y 00:00:00");
}
//traitement des tableaux
//heure debut
//var_dump($datedeb, $datefin);exit;
$heureDebut = explode(' ', $datedeb);
$heureFin = explode(' ', $datefin);
//var_dump($datedeb);
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
//var_dump($silivre);exit;
//var_dump($datedebarray);exit;
//$heure= " 07:00:00";
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
//var_dump($paramdeb,$paramfin);exit;
$sql = "SELECT DISTINCT c
FROM App\Entity\stock\Commande c ";
$sql .= " INNER JOIN c.lignecommandes l ";
$sql .= " INNER JOIN l.produit p ";
if($type==0){
$sql .= " LEFT JOIN c.fournisseur f ";
}
if($type==6 || $type==5 ){
$sql .= " LEFT JOIN c.surfaceannee s ";
}
//var_dump($type);exit;
//$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN c.utilisateur u ";
$sql .= " INNER JOIN c.abonne a ";
if($clientId!=0){
$sql .= " INNER JOIN c.client cl ";
}
//$sql .= " INNER JOIN s.ville v ";
$sql .= " WHERE c.annule != 1 and 1=1 ";
//var_dump($sql);exit;
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.datePublication >= " . " '" . $paramdeb." ".$heureDebut[1] . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.datePublication <= " . " '" . $paramfin." ".$heureFin[1] . "' " : $sql .= '';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
if($type==6 || $type==5 ){
( $surfaceId == '0' || $surfaceId == '') ? $sql .= '' : $sql .= ' AND s.id = :surfaceId';
}
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $sql .= ' AND a.id = :abonneId';
$separateur ="";
if($type == 3)
$separateur = "( ";
$sql .= ' AND'. $separateur .' c.typeCommande = :typec ';
if($type == 3)
$sql .= ' OR c.typeCommande = :typec1 )';
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND p.id = :prod';
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $clientId == '0' || $clientId == '') ? $sql .= '' : $sql .= ' AND cl.id =:clientId ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
( $retrait == '0' || $retrait == '') ? $sql .= '' : $sql .= ' AND c.siRetrait = :retrait';
( $siCredit == '0' || $siCredit == '') ? $sql .= '' : $sql .= ' AND c.siCredit = :siCredit';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} elseif ($silivre == 3) {
$sql .= ' AND c.etatCommande =2';
} elseif ($silivre == 4) {
$sql .= ' AND l.quantiteLivre !=0';
} else {
$sql .= ' AND (l.quantiteLivre !=0 AND c.etatCommande !=2) or l.quantiteLivre =0 ';
}
}
/** Fin critère recherche **/
$sql .= ' ORDER BY c.id DESC ';
//var_dump($sql, $clientId);exit;
//var_dump($prod); var_dump($sql);exit;
//var_dump($silivre,$sql, $abonneId);exit;
/** debut parametres * */
( $prod == '0' || $prod == '') ? $sql .= '' : $param['prod'] = $prod;
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $param['abonneId'] = $abonneId;
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
if($type==6 || $type==5 ){
( $surfaceId == '0' || $surfaceId == '') ? $sql .= '' : $param['surfaceId'] = $surfaceId ;
}
( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
( $clientId == '0' || $clientId == '') ? $sql .= '' : $param['clientId'] = $clientId;
$param['typec'] = $type ;
if($type == 3)
$param['typec1'] = 4 ;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
($retrait == '0' || $retrait == '') ? $sql .= '' : $param['retrait'] = $retrait;
($siCredit == '0' || $siCredit == '') ? $sql .= '' : $param['siCredit'] = $siCredit;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
if ($typeLimite == 1) {
$query->setMaxResults(5);
}
//var_dump($query->getSQL());exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
// var_dump($query->getSql());exit;
return $query->getResult();
}
public function getCountInfoCommandeByAnnee($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $prod = 0,$type=0,$typeLimite = 0, $nbParPage = 20, $pageActuelle = 1,$abonneId=0,$retrait=0, $clientId = 0, $siCredit=0,$surfaceId=0, $anneeId=0,$producteurId=0, $typeCulture=0, $infoAnnee =0 ) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000000;
/*if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}*/
if($infoAnnee == 0){
if ($datedeb == 0 && $datefin == 0 && $anneeId==0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = "01/01/".$dateJour->format("Y")." 00:00:00"; //$dateJour->format("d/m/Y 00:00:00");//
$datefin = "31/12/".$dateJour->format("Y")." 00:00:00"; //$premierDate->add(new DateInterval('P1M'))->format("d/m/Y 00:00:00"); //$dateJour->format("d/m/Y 23:59:59");//
//$datefin = $dateMoi->format("d/m/Y 00:00:00");
}
}else{
$datedeb = '01/01/'.$infoAnnee.' 00:00:00';
$datefin = '31/12/'.$infoAnnee.' 23:59:59';
}
//traitement des tableaux
$heureDebut = explode(' ', $datedeb);
$heureFin = explode(' ', $datefin);
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
//var_dump($paramdeb,$paramfin);exit;
$sql = "SELECT DISTINCT(l.id), SUM(l.quantite) as quantite
FROM App\Entity\stock\Commande c ";
$sql .= " INNER JOIN c.lignecommandes l ";
$sql .= " INNER JOIN l.produit p ";
if($type==0){
$sql .= " LEFT JOIN c.fournisseur f ";
}
if($type==6 || $type==5 ){
$sql .= " LEFT JOIN c.surfaceannee s ";
}
if($producteurId !=0)
$sql .= " INNER JOIN c.producteur pr ";
if($anneeId !=0 ){
$sql .= " INNER JOIN c.anneecampagne ac ";
}
//var_dump($type);exit;
//$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN c.utilisateur u ";
$sql .= " INNER JOIN c.abonne a ";
if($clientId!=0){
$sql .= " INNER JOIN c.client cl ";
}
//$sql .= " INNER JOIN s.ville v ";
$sql .= " WHERE c.annule != 1 and 1=1 ";
//var_dump($sql);exit;
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.datePublication >= " . " '" . $paramdeb." ".$heureDebut[1] . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.datePublication <= " . " '" . $paramfin." ".$heureFin[1] . "' " : $sql .= '';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
if($type==6 || $type==5 ){
( $surfaceId == '0' || $surfaceId == '') ? $sql .= '' : $sql .= ' AND s.id = :surfaceId';
}
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $sql .= ' AND a.id = :abonneId';
( $anneeId == '0' || $anneeId == '') ? $sql .= '' : $sql .= ' AND ac.id = :anneeId';
( $producteurId == '0' || $producteurId == '') ? $sql .= '' : $sql .= ' AND pr.id = :producteurId';
$separateur ="";
if($type == 3)
$separateur = "( ";
$sql .= ' AND'. $separateur .' c.typeCommande = :typec ';
if($type == 3)
$sql .= ' OR c.typeCommande = :typec1 )';
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND p.id = :prod';
( $typeCulture == '0' || $typeCulture == '') ? $sql .= '' : $sql .= ' AND p.typeQualite = :typeQualite';
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $clientId == '0' || $clientId == '') ? $sql .= '' : $sql .= ' AND cl.id =:clientId ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
( $retrait == '0' || $retrait == '') ? $sql .= '' : $sql .= ' AND c.siRetrait = :retrait';
( $siCredit == '0' || $siCredit == '') ? $sql .= '' : $sql .= ' AND c.siCredit = :siCredit';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} elseif ($silivre == 3) {
$sql .= ' AND c.etatCommande =2';
} elseif ($silivre == 4) {
$sql .= ' AND l.quantiteLivre !=0';
} else {
$sql .= ' AND (l.quantiteLivre !=0 AND c.etatCommande !=2) or l.quantiteLivre =0 ';
}
}
/** Fin critère recherche **/
$sql .= ' ORDER BY c.id DESC ';
//var_dump($sql, $clientId);exit;
//var_dump($prod); var_dump($sql);exit;
//var_dump($silivre,$sql, $abonneId);exit;
/** debut parametres * */
( $prod == '0' || $prod == '') ? $sql .= '' : $param['prod'] = $prod;
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $param['abonneId'] = $abonneId;
( $producteurId == '0' || $producteurId == '') ? $sql .= '' : $param['producteurId'] = $producteurId;
( $anneeId == '0' || $anneeId == '') ? $sql .= '' : $param['anneeId'] = $anneeId;
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
if($type==6 || $type==5 ){
( $surfaceId == '0' || $surfaceId == '') ? $sql .= '' : $param['surfaceId'] = $surfaceId ;
}
( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
( $clientId == '0' || $clientId == '') ? $sql .= '' : $param['clientId'] = $clientId;
( $typeCulture == '0' || $typeCulture == '') ? $sql .= '' : $param['typeCulture'] = $typeCulture;
$param['typec'] = $type ;
if($type == 3)
$param['typec1'] = 4 ;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
($retrait == '0' || $retrait == '') ? $sql .= '' : $param['retrait'] = $retrait;
($siCredit == '0' || $siCredit == '') ? $sql .= '' : $param['siCredit'] = $siCredit;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
if ($typeLimite == 1) {
$query->setMaxResults(5);
}
// var_dump($query->getSQL(), $nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $type, $producteurId, $typeCulture, $infoAnnee ); //exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
//var_dump($query->getSql());exit;
return $query->getResult();
}
public function getListeRechercheCommandeAPI($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $prod = 0,$type=0,$typeLimite = 0, $nbParPage = 20, $pageActuelle = 1,$abonneId=0,$retrait=0, $clientId = 0, $siCredit=0,$surfaceId=0) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000000;
/*if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}*/
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $dateJour->format("d/m/Y 00:00:00");//$premierDate->format("d/m/Y 00:00:00");
$datefin = $dateJour->format("d/m/Y 23:59:59");//$premierDate->add(new DateInterval('P1M'));
//$datefin = $dateMoi->format("d/m/Y 00:00:00");
}
//traitement des tableaux
//heure debut
//var_dump($datedeb, $datefin);exit;
$heureDebut = explode(' ', $datedeb);
$heureFin = explode(' ', $datefin);
//var_dump($datedeb);
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
//var_dump($silivre);exit;
//var_dump($datedebarray);exit;
//$heure= " 07:00:00";
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
//var_dump($paramdeb,$paramfin);exit;
$sql = "SELECT DISTINCT c.id, c.codeCommande, c.datePublication, c.montantCommande
FROM App\Entity\stock\Commande c ";
//$sql .= " INNER JOIN c.lignecommandes l ";
//$sql .= " INNER JOIN l.produit p ";
// $sql .= " INNER JOIN l.prixrigueur pr ";
if($type==0){
$sql .= " LEFT JOIN c.fournisseur f ";
}
if($type==6){
$sql .= " LEFT JOIN c.surfaceannee s ";
}
//var_dump($type);exit;
//$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN c.utilisateur u ";
$sql .= " INNER JOIN c.abonne a ";
if($clientId!=0){
$sql .= " INNER JOIN c.client cl ";
}
//$sql .= " INNER JOIN s.ville v ";
$sql .= " WHERE c.annule != 1 and 1=1 ";
//var_dump($sql);exit;
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
// ( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.datePublication >= " . " '" . $paramdeb." ".$heureDebut[1] . "' " : $sql .= '';
//( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.datePublication <= " . " '" . $paramfin." ".$heureFin[1] . "' " : $sql .= '';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
if($type==6){
( $surfaceId == '0' || $surfaceId == '') ? $sql .= '' : $sql .= ' AND s.id = :surfaceId';
}
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $sql .= ' AND a.id = :abonneId';
$separateur ="";
if($type == 3)
$separateur = "( ";
$sql .= ' AND'. $separateur .' c.typeCommande = :typec ';
if($type == 3)
$sql .= ' OR c.typeCommande = :typec1 )';
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND p.id = :prod';
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $clientId == '0' || $clientId == '') ? $sql .= '' : $sql .= ' AND cl.id =:clientId ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
( $retrait == '0' || $retrait == '') ? $sql .= '' : $sql .= ' AND c.siRetrait = :retrait';
( $siCredit == '0' || $siCredit == '') ? $sql .= '' : $sql .= ' AND c.siCredit = :siCredit';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} elseif ($silivre == 3) {
$sql .= ' AND c.etatCommande =2';
} elseif ($silivre == 4) {
$sql .= ' AND l.quantiteLivre !=0';
} else {
$sql .= ' AND (l.quantiteLivre !=0 AND c.etatCommande !=2) or l.quantiteLivre =0 ';
}
}
/** Fin critère recherche **/
$sql .= ' ORDER BY c.id DESC ';
//var_dump($sql, $clientId, $type, $abonneId);exit;
//var_dump($prod); var_dump($sql);exit;
//var_dump($silivre,$sql, $abonneId);exit;
/** debut parametres * */
( $prod == '0' || $prod == '') ? $sql .= '' : $param['prod'] = $prod;
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $param['abonneId'] = $abonneId;
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
if($type==6){
( $surfaceId == '0' || $surfaceId == '') ? $sql .= '' : $param['surfaceId'] = $surfaceId ;
}
( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
( $clientId == '0' || $clientId == '') ? $sql .= '' : $param['clientId'] = $clientId;
$param['typec'] = $type ;
if($type == 3)
$param['typec1'] = 4 ;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
($retrait == '0' || $retrait == '') ? $sql .= '' : $param['retrait'] = $retrait;
($siCredit == '0' || $siCredit == '') ? $sql .= '' : $param['siCredit'] = $siCredit;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
if ($typeLimite == 1) {
$query->setMaxResults(5);
}
//var_dump($query->getSQL());exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
// var_dump(count($query->getResult()));exit;
return $query->getResult();
}
public function getListeRechercheLigneCommandeAPI($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $prod = 0,$type=0,$typeLimite = 0, $nbParPage = 20, $pageActuelle = 1,$abonneId=0,$retrait=0, $clientId = 0, $siCredit=0,$surfaceId=0) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000000;
/*if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}*/
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $dateJour->format("d/m/Y 00:00:00");//$premierDate->format("d/m/Y 00:00:00");
$datefin = $dateJour->format("d/m/Y 23:59:59");//$premierDate->add(new DateInterval('P1M'));
//$datefin = $dateMoi->format("d/m/Y 00:00:00");
}
//traitement des tableaux
//heure debut
//var_dump($datedeb, $datefin);exit;
$heureDebut = explode(' ', $datedeb);
$heureFin = explode(' ', $datefin);
//var_dump($datedeb);
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
//var_dump($silivre);exit;
//var_dump($datedebarray);exit;
//$heure= " 07:00:00";
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
//var_dump($paramdeb,$paramfin);exit;
$sql = "SELECT DISTINCT c.id, c.codeCommande, p.nomProduit, l.quantite, c.datePublication, pr.infoPrixRigueur as prix
FROM App\Entity\stock\Commande c ";
$sql .= " INNER JOIN c.lignecommandes l ";
$sql .= " INNER JOIN l.produit p ";
$sql .= " INNER JOIN l.prixrigueur pr ";
if($type==0){
$sql .= " LEFT JOIN c.fournisseur f ";
}
if($type==6){
$sql .= " LEFT JOIN c.surfaceannee s ";
}
//var_dump($type);exit;
//$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN c.utilisateur u ";
$sql .= " INNER JOIN c.abonne a ";
if($clientId!=0){
$sql .= " INNER JOIN c.client cl ";
}
//$sql .= " INNER JOIN s.ville v ";
$sql .= " WHERE c.annule != 1 and 1=1 ";
//var_dump($sql);exit;
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
// ( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.datePublication >= " . " '" . $paramdeb." ".$heureDebut[1] . "' " : $sql .= '';
//( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.datePublication <= " . " '" . $paramfin." ".$heureFin[1] . "' " : $sql .= '';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
if($type==6){
( $surfaceId == '0' || $surfaceId == '') ? $sql .= '' : $sql .= ' AND s.id = :surfaceId';
}
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $sql .= ' AND a.id = :abonneId';
$separateur ="";
if($type == 3)
$separateur = "( ";
$sql .= ' AND'. $separateur .' c.typeCommande = :typec ';
if($type == 3)
$sql .= ' OR c.typeCommande = :typec1 )';
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND p.id = :prod';
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $clientId == '0' || $clientId == '') ? $sql .= '' : $sql .= ' AND cl.id =:clientId ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
( $retrait == '0' || $retrait == '') ? $sql .= '' : $sql .= ' AND c.siRetrait = :retrait';
( $siCredit == '0' || $siCredit == '') ? $sql .= '' : $sql .= ' AND c.siCredit = :siCredit';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} elseif ($silivre == 3) {
$sql .= ' AND c.etatCommande =2';
} elseif ($silivre == 4) {
$sql .= ' AND l.quantiteLivre !=0';
} else {
$sql .= ' AND (l.quantiteLivre !=0 AND c.etatCommande !=2) or l.quantiteLivre =0 ';
}
}
/** Fin critère recherche **/
$sql .= ' ORDER BY c.id DESC ';
//var_dump($sql, $clientId, $type, $abonneId);exit;
//var_dump($prod); var_dump($sql);exit;
//var_dump($silivre,$sql, $abonneId);exit;
/** debut parametres * */
( $prod == '0' || $prod == '') ? $sql .= '' : $param['prod'] = $prod;
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $param['abonneId'] = $abonneId;
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
if($type==6){
( $surfaceId == '0' || $surfaceId == '') ? $sql .= '' : $param['surfaceId'] = $surfaceId ;
}
( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
( $clientId == '0' || $clientId == '') ? $sql .= '' : $param['clientId'] = $clientId;
$param['typec'] = $type ;
if($type == 3)
$param['typec1'] = 4 ;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
($retrait == '0' || $retrait == '') ? $sql .= '' : $param['retrait'] = $retrait;
($siCredit == '0' || $siCredit == '') ? $sql .= '' : $param['siCredit'] = $siCredit;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
if ($typeLimite == 1) {
$query->setMaxResults(5);
}
//var_dump($query->getSQL());exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
// var_dump(count($query->getResult()));exit;
return $query->getResult();
}
public function getListeRechercheCommandeTableAjax($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $prod = 0,$type=0,$typeLimite = 0, $nbParPage = 20, $pageActuelle = 1,$abonneId=0,$retrait=0, $clientId = 0, $siCredit=0) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000000;
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}
//traitement des tableaux
//var_dump($util);exit;
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
//var_dump($datedeb, $datefin);exit;
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
//var_dump($paramdeb,$paramfin);exit;
$sql = "SELECT DISTINCT c.codeCommande,c.id, c.datePublication, u.nom , c.montantCommande, tn.nomTable
FROM App\Entity\stock\Commande c ";
// $sql .= " INNER JOIN c.lignecommandes l ";
//$sql .= " INNER JOIN l.produit p ";
if($type==0){
$sql .= " INNER JOIN l.fournisseur f ";
}
//$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN c.utilisateur u ";
$sql .= " INNER JOIN c.abonne a ";
$sql .= " INNER JOIN c.tableMange tn ";
if($clientId!=0){
$sql .= " INNER JOIN c.client cl ";
$sql .= " INNER JOIN cl.utilisateur ut ";
}
//$sql .= " INNER JOIN s.ville v ";
$sql .= " WHERE c.annule != 1 and 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.dateCommande >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.dateCommande <= " . " '" . $paramfin . "' " : $sql .= '';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $sql .= ' AND a.id = :abonneId';
$sql .= ' AND c.typeCommande = :typec';
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND p.id = :prod';
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $clientId == '0' || $clientId == '') ? $sql .= '' : $sql .= ' AND cl.id =:clientId ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
( $retrait == '0' || $retrait == '') ? $sql .= '' : $sql .= ' AND c.siRetrait = :retrait';
$sql .= ' AND c.siCredit = :siCredit';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} elseif ($silivre == 3) {
$sql .= ' AND c.etatCommande =2';
} elseif ($silivre == 4) {
$sql .= ' AND l.quantiteLivre !=0';
} else {
$sql .= ' AND (l.quantiteLivre !=0 AND c.etatCommande !=2) or l.quantiteLivre =0 ';
}
}
/** Fin critère recherche **/
$sql .= ' ORDER BY c.id DESC ';
//var_dump($prod); var_dump($sql);exit;
/** debut parametres * */
( $prod == '0' || $prod == '') ? $sql .= '' : $param['prod'] = $prod;
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $param['abonneId'] = $abonneId;
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
( $clientId == '0' || $clientId == '') ? $sql .= '' : $param['clientId'] = $clientId;
$param['typec'] = $type ;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
($retrait == '0' || $retrait == '') ? $sql .= '' : $param['retrait'] = $retrait;
$param['siCredit'] = $siCredit;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
if ($typeLimite == 1) {
$query->setMaxResults(5);
}
//var_dump($query->getSql());exit;
return $query->getResult();
}
public function getListeRechercheCommandeAjax($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $prod = 0,$type=0,$typeLimite = 0, $nbParPage = 20, $pageActuelle = 1,$abonneId=0,$retrait=0, $clientId = 0, $siCredit=0) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000000;
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}
//traitement des tableaux
//var_dump($util);exit;
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
//var_dump($datedeb, $datefin);exit;
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
//var_dump($paramdeb,$paramfin);exit;
$sql = "SELECT DISTINCT c.codeCommande,c.id, c.datePublication, u.nom , c.montantCommande, t.nomTable , ut.nom as nomClient
FROM App\Entity\stock\Commande c ";
// $sql .= " INNER JOIN c.lignecommandes l ";
//$sql .= " INNER JOIN l.produit p ";
if($type==0){
$sql .= " INNER JOIN l.fournisseur f ";
}
$sql .= " lEFT JOIN c.tableMange t ";
$sql .= " INNER JOIN c.utilisateur u ";
$sql .= " INNER JOIN c.abonne a ";
//if($clientId!=0){
$sql .= " lEFT JOIN c.client cl ";
$sql .= " lEFT JOIN cl.utilisateur ut ";
//}
//$sql .= " INNER JOIN s.ville v ";
$sql .= " WHERE c.annule != 1 and 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.dateCommande >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.dateCommande <= " . " '" . $paramfin . "' " : $sql .= '';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $sql .= ' AND a.id = :abonneId';
$separateur ="";
if($type == 3)
$separateur = "(";
$sql .= ' AND '.$separateur .'c.typeCommande = :typec';
if($type == 3)
$sql .= ' OR c.typeCommande = :typec1)';
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND p.id = :prod';
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $clientId == '0' || $clientId == '') ? $sql .= '' : $sql .= ' AND cl.id =:clientId ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
( $retrait == '0' || $retrait == '') ? $sql .= '' : $sql .= ' AND c.siRetrait = :retrait';
$sql .= ' AND c.siCredit = :siCredit';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} elseif ($silivre == 3) {
$sql .= ' AND c.etatCommande =2';
} elseif ($silivre == 4) {
$sql .= ' AND l.quantiteLivre !=0';
} else {
$sql .= ' AND (l.quantiteLivre !=0 AND c.etatCommande !=2) or l.quantiteLivre =0 ';
}
}
//var_dump($prod); var_dump($sql);exit;
/** debut parametres * */
( $prod == '0' || $prod == '') ? $sql .= '' : $param['prod'] = $prod;
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $param['abonneId'] = $abonneId;
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
( $clientId == '0' || $clientId == '') ? $sql .= '' : $param['clientId'] = $clientId;
$param['typec'] = $type ;
if($type == 3)
$param['typec1'] = 4 ;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
($retrait == '0' || $retrait == '') ? $sql .= '' : $param['retrait'] = $retrait;
$param['siCredit'] = $siCredit;
/** Fin critère recherche **/
$sql .= ' ORDER BY c.id DESC ';
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
if ($typeLimite == 1) {
$query->setMaxResults(5);
}
//var_dump($sql);exit;
return $query->getResult();
}
public function getListeLivraisonCommande($idCommande) {
$sql = "SELECT l
FROM App\Entity\stock\Livrer l ";
$sql .= " INNER JOIN l.infolivrer i ";
$sql .= " INNER JOIN l.lignecommande li ";
$sql .= " INNER JOIN li.commande c ";
$sql .= " INNER JOIN i.fournisseur f ";
$sql .= " WHERE c.annule != 1 and 1=1 ";
( $idCommande == '0' || $idCommande == '') ? $sql .= '' : $sql .= ' AND c.id = :commande';
$sql .= ' ORDER BY i.dateLivraison DESC ';
/** Fin critère recherche * */
// var_dump($sql);exit;
// var_dump($silivre,$sql);exit;
/** debut parametres * */
( $idCommande == '0' || $idCommande == '') ? $sql .= '' : $param['commande'] = $idCommande;
$queryLivr = $this->_em->createQuery($sql);
$queryLivr->setParameters($param);
return $queryLivr->getResult();
}
public function getListeRechercheInfoTotalCommande($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $prod = 0, $typeLimite = 0, $nbParPage = 20, $pageActuelle = 1) {
$param = array();
$param2 = array();
$tabDeDonnees = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
//var_dump($datedeb, $datefin);exit;
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}
//traitement des tableaux
//var_dump($util);exit;
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
//var_dump($paramdeb,$paramfin);exit;
$sql = "SELECT DISTINCT c
FROM App\Entity\stock\Commande c ";
$sql .= " INNER JOIN c.lignecommandes l ";
$sql .= " INNER JOIN l.produit p ";
$sql .= " INNER JOIN l.fournisseur f ";
$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN s.utilisateur u ";
$sql .= " INNER JOIN s.ville v ";
$sql .= " WHERE c.annule != 1 and 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.dateCommande >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.dateCommande <= " . " '" . $paramfin . "' " : $sql .= '';
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND p.id = :prod';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} elseif ($silivre == 3) {
$sql .= ' AND c.etatCommande =2';
} elseif ($silivre == 4) {
$sql .= ' AND l.quantiteLivre !=0';
} else {
$sql .= ' AND (l.quantiteLivre !=0 AND c.etatCommande !=2) or l.quantiteLivre =0 ';
}
}
/** Fin critère recherche * */
$sql .= ' ORDER BY c.dateCommande ASC ';
/** debut parametres * */
//var_dump($sql);
( $prod == '0' || $prod == '') ? $sql .= '' : $param['prod'] = $prod;
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
$siFin = 0;
$listeCommande = $query->getResult();
//var_dump($query->getSQL());exit;
$i = 0;
$k = 0;
$n = 0;
foreach ($listeCommande as $uneCommande) {
$tabDeDonnees[$i]['code'] = $uneCommande->getCodeCommande();
$tabDeDonnees[$i]['codeCommandeLivraison'] =" ";
$tabDeDonnees[$i]['date'] = $uneCommande->getDateCommande();
$tabDeDonnees[$i]['zone'] = $uneCommande->getFournisseur()->getVille()->getNomVille();
$tabDeDonnees[$i]['collecteur'] = $uneCommande->getFournisseur()->getNomFournisseur();
$tabDeDonnees[$i]['typeOperation'] = 1;
$tabDeDonnees[$i]['quantite'] = $uneCommande->getLigneCommandes()[0]->getQuantite();
$tabDeDonnees[$i]['prixUnitaire'] = $uneCommande->getLigneCommandes()[0]->getPrixrigueur()->getInfoPrixRigueur();
$j = $k + 1;
$nombreTotal = count($listeCommande);
if ($j == $nombreTotal) {
--$j;
$siFin = 1;
}
if ($listeCommande[$j]->getDateCommande()->format("Y-m-d") != $listeCommande[$k]->getDateCommande()->format("Y-m-d") || $siFin == 1) {
++$n;
// $sql = "SELECT l
// FROM App\Entity\stock\Livrer l ";
//
// $sql .= " INNER JOIN l.infolivrer i ";
// $sql .= " INNER JOIN i.fournisseur f ";
//
// $sql .= " WHERE 1=1 ";
$sql = "SELECT i
FROM App\Entity\stock\InfoLivrer i ";
$sql .= " INNER JOIN i.fournisseur f ";
$sql .= " INNER JOIN i.livrers l ";
$sql .= " INNER JOIN l.lignecommande lc ";
$sql .= " INNER JOIN lc.produit p ";
$sql .= " WHERE 1=1 ";
// if($n==3){
// var_dump($listeCommande[$j]->getDateCommande()->format("Y-m-d"),$listeCommande[$k]->getDateCommande()->format("Y-m-d") );exit;
// }
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
if($siFin == 0){
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND i.dateLivraison >= " . " '" . $listeCommande[$k]->getDateCommande()->format("Y-m-d") . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND i.dateLivraison < " . " '" . $listeCommande[$j]->getDateCommande()->format("Y-m-d") . "' " : $sql .= '';
}else{
//var_dump($siFin);exit;
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND i.dateLivraison >= " . " '" . $listeCommande[$j]->getDateCommande()->format("Y-m-d") . "' " : $sql .= '';
}
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND p.id = :prod';
$sql .= ' ORDER BY i.dateLivraison ASC ';
/** Fin critère recherche * */
//var_dump($sql);exit;
// var_dump($silivre,$sql);exit;
/** debut parametres * */
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param2['nomcol'] = $nomcol;
( $prod == '0' || $prod == '') ? $sql .= '' : $param2['prod'] = $prod;
$queryLivr = $this->_em->createQuery($sql);
$queryLivr->setParameters($param2);
$listeLivraison = $queryLivr->getResult();
foreach ($listeLivraison as $uneLivraison) {
++$i;
$tabDeDonnees[$i]['code'] = $uneLivraison->getRefBonLivraison();
$tabDeDonnees[$i]['codeCommandeLivraison'] = "";//$uneLivraison->getLignecommande()->getCommande()->getCodeCommande();
$tabDeDonnees[$i]['date'] = $uneLivraison->getDateLivraison();
$tabDeDonnees[$i]['zone'] = $uneLivraison->getFournisseur()->getVille()->getNomVille();
$tabDeDonnees[$i]['collecteur'] = $uneLivraison->getFournisseur()->getNomFournisseur();
$tabDeDonnees[$i]['typeOperation'] = 2;
$tabDeDonnees[$i]['quantite'] = $uneLivraison->getNbreTotalLivre();
$tabDeDonnees[$i]['prixUnitaire'] = " ";//$uneLivraison->getLignecommande()->getPrixrigueur()->getInfoPrixRigueur();
}
}
// var_dump($sql);exit;
++$i;
++$k;
//var_dump($tabDeDonnees);exit;
}
return $tabDeDonnees;
}
public function getStatsRechercheCommande($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $prod = '0', $type=0, $nbParPage = 20, $pageActuelle = 1, $niveau = 4, $abonneId=0, $caisseId=0 ) {
// var_dump()
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
$infoVille = $this->getStringSqlVille($niveau);
//
/*if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}*/
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $dateJour->format("31/12/1990 00:00:00");//$premierDate->format("d/m/Y 00:00:00");
$datefin = $dateJour->format("d/m/Y 23:59:59");//$premierDate->add(new DateInterval('P1M'));
//$datefin = $dateMoi->format("d/m/Y 00:00:00");
}
//var_dump($datedeb, $datefin);exit;
//traitement des tableaux
//heure debut
$heureDebut = explode(' ', $datedeb);
$heureFin = explode(' ', $datefin);
//var_dump($heureDebut, $heureFin);exit;
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
$sql = "SELECT sum(l.quantite) as quantiteTotal, sum(l.quantiteLivre) as quantiteTotalLivre, sum(c.montantCommande) as montantTotal, sum(l.quantiteLivre*pri.infoPrixRigueur) as montantTotalLivre , sum(l.quantite*pri.infoPrixRigueur) as montantSemence
FROM App\Entity\stock\Commande c ";
$sql .= " INNER JOIN c.lignecommandes l ";
$sql .= " INNER JOIN l.prixrigueur pri ";
if($nomcol!=0){
$sql .= " INNER JOIN c.fournisseur f ";
}
if($caisseId !=0)
$sql .= " INNER JOIN c.caisse cs ";
$sql .= " INNER JOIN l.produit pr ";
$sql .= " INNER JOIN c.abonne a ";
/*if($prod != 1){
$sql .= " INNER JOIN l.producteur p ";
$sql .= $infoVille[0];
}else{
$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN s.ville v ";
$sql .= " INNER JOIN s.utilisateur u ";
}*/
$sql .= " WHERE c.annule != 1 and 1=1 and l.etatLigneCommande !=2 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.datePublication >= " . " '" . $paramdeb ." ".$heureDebut[1] . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.datePublication <= " . " '" . $paramfin ." ".$heureFin[1] . "' " : $sql .= '';
//( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $sql .= ' AND a.id = :abonneId';
//( $caisseId == '0' || $caisseId == '') ? $sql .= '' : $sql .= ' AND cs.id = :caisseId';
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND pr.id = :prod';
$separateur ="";
if($type == 3)
$separateur = "( ";
$sql .= ' AND'. $separateur .' c.typeCommande = :typec ';
if($type == 3)
$sql .= ' OR c.typeCommande = :typec1)';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
/*if($prod != 1){
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v3.id = :ville';
}else{
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
}*/
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} else {
$sql .= ' AND c.etatCommande =2';
}
}
if($caisseId !=0){
( $caisseId == '0' || $caisseId == '') ? $sql .= '' : $sql .= ' AND cs.id = :caisseId';
( $caisseId == '0' || $caisseId == '') ? $sql .= '' : $param['caisseId'] = $caisseId;
}else{
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $sql .= ' AND a.id = :abonneId';
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $param['abonneId'] = $abonneId;
$sql .= ' AND c.caisse is null';
}
/** Fin critère recherche * */
$sql .= ' ORDER BY c.id DESC ';
/** debut parametres * */
$param['typec'] = $type;
( $prod == '0' || $prod == '') ? $sql .= '' : $param['prod'] = $prod;
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
//( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $param['abonneId'] = $abonneId;
//( $caisseId == '0' || $caisseId == '') ? $sql .= '' : $param['caisseId'] = $caisseId;
// ( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
$param['typec'] = $type ;
if($type == 3)
$param['typec1'] = 4 ;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
if($type !=0){
//
}
//var_dump($sql,$caisseId );exit;
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
//var_dump( $sql );exit;
if($type !=0){
//var_dump( $type , $query->getSQL(), $type );exit;
}
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
// var_dump($query->getSQL());exit;
return $query->getResult();
}
public function getStatsRechercheCommandeAnnexe($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $prod = '0', $type=0, $nbParPage = 20, $pageActuelle = 1, $niveau = 4, $abonneId=0, $caisseId=0 , $produitMere=0 ) {
// var_dump()
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
$infoVille = $this->getStringSqlVille($niveau);
//var_dump($datedeb, $datefin);exit;
//traitement des tableaux
//heure debut
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $dateJour->format("d/m/Y 00:00:00");//$premierDate->format("d/m/Y 00:00:00");
$datefin = $dateJour->format("d/m/Y 23:59:59");//$premierDate->add(new DateInterval('P1M'));
//$datefin = $dateMoi->format("d/m/Y 00:00:00");
}
//var_dump($datedeb, $datefin);exit;
//traitement des tableaux
//heure debut
$heureDebut = explode(' ', $datedeb);
$heureFin = explode(' ', $datefin);
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
$sql = "SELECT sum(cp.value) as quantiteTotal, sum(l.quantiteLivre) as quantiteTotalLivre, sum(c.montantCommande) as montantTotal, sum(l.quantiteLivre*pri.infoPrixRigueur) as montantTotalLivre , sum(l.quantite*pri.infoPrixRigueur) as montantSemence
FROM App\Entity\stock\Commande c ";
$sql .= " INNER JOIN c.lignecommandes l ";
$sql .= " INNER JOIN l.prixrigueur pri ";
if($nomcol!=0){
$sql .= " INNER JOIN l.fournisseur f ";
}
if($caisseId !=0)
$sql .= " INNER JOIN c.caisse cs ";
else
$sql .= " INNER JOIN c.abonne a ";
$sql .= " INNER JOIN l.produit pr ";
$sql .= " INNER JOIN pr.carateristiqueproduits cp ";
$sql .= " INNER JOIN cp.produitparent pp ";
/*if($prod != 1){
$sql .= " INNER JOIN l.producteur p ";
$sql .= $infoVille[0];
}else{
$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN s.ville v ";
$sql .= " INNER JOIN s.utilisateur u ";
}*/
$sql .= " WHERE c.annule != 1 and 1=1 and l.etatLigneCommande !=2 and cp.etatCaratersitiqueProduit = 1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.datePublication >= " . " '" . $paramdeb ." ".$heureDebut[1] . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.datePublication <= " . " '" . $paramfin ." ".$heureFin[1] . "' " : $sql .= '';
if($caisseId ==0)
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $sql .= ' AND a.id = :abonneId';
( $produitMere == '0' || $produitMere == '') ? $sql .= '' : $sql .= ' AND pp.id = :produitMere';
( $caisseId == '0' || $caisseId == '') ? $sql .= '' : $sql .= ' AND cs.id = :caisseId';
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND pr.id = :prod';
$sql .= ' AND c.typeCommande = :typec';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
/*if($prod != 1){
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v3.id = :ville';
}else{
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
}*/
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} else {
$sql .= ' AND c.etatCommande =2';
}
}
//if($caisseId ==0)
//$sql .= ' AND cs.id is null ';
/** Fin critère recherche * */
$sql .= ' ORDER BY c.id DESC ';
/** debut parametres * */
$param['typec'] = $type;
( $prod == '0' || $prod == '') ? $sql .= '' : $param['prod'] = $prod;
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
if($caisseId ==0)
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $param['abonneId'] = $abonneId;
( $caisseId == '0' || $caisseId == '') ? $sql .= '' : $param['caisseId'] = $caisseId;
( $produitMere == '0' || $produitMere == '') ? $sql .= '' : $param['produitMere'] = $produitMere;
// ( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
if($type !=0){
//var_dump($sql,$type );exit;
}
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
// var_dump( $type , $query->getSQL(), $type );exit;
if($type !=0){
//var_dump( $type , $query->getSQL(), $type );exit;
}
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
//var_dump($type, $query->getSQL(), $produitMere, $prod );exit;
return $query->getResult();
}
public function getPortionProduit($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $prod = '0', $type=0, $nbParPage = 20, $pageActuelle = 1, $niveau = 4, $abonneId=0, $caisseId=0 , $produitMere=0 ) {
// var_dump()
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
$infoVille = $this->getStringSqlVille($niveau);
//var_dump($datedeb, $datefin);exit;
//traitement des tableaux
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
$sql = "SELECT count(cp.id) as total
FROM App\Entity\stock\Commande c ";
$sql .= " INNER JOIN c.lignecommandes l ";
$sql .= " INNER JOIN l.prixrigueur pri ";
if($nomcol!=0){
$sql .= " INNER JOIN l.fournisseur f ";
}
if($caisseId !=0)
$sql .= " INNER JOIN c.caisse cs ";
$sql .= " INNER JOIN l.produit pr ";
$sql .= " INNER JOIN c.abonne a ";
$sql .= " INNER JOIN pr.carateristiqueproduits cp ";
$sql .= " INNER JOIN cp.produitparent pp ";
/*if($prod != 1){
$sql .= " INNER JOIN l.producteur p ";
$sql .= $infoVille[0];
}else{
$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN s.ville v ";
$sql .= " INNER JOIN s.utilisateur u ";
}*/
$sql .= " WHERE c.annule != 1 and 1=1 and l.etatLigneCommande !=2 and cp.etatCaratersitiqueProduit = 1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.dateCommande >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.dateCommande <= " . " '" . $paramfin . "' " : $sql .= '';
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $sql .= ' AND a.id = :abonneId';
( $produitMere == '0' || $produitMere == '') ? $sql .= '' : $sql .= ' AND pp.id = :produitMere';
( $caisseId == '0' || $caisseId == '') ? $sql .= '' : $sql .= ' AND cs.id = :caisseId';
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND pr.id = :prod';
$sql .= ' AND c.typeCommande = :typec';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
/*if($prod != 1){
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v3.id = :ville';
}else{
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
}*/
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} else {
$sql .= ' AND c.etatCommande =2';
}
}
/** Fin critère recherche * */
$sql .= ' ORDER BY c.id DESC ';
/** debut parametres * */
$param['typec'] = $type;
( $prod == '0' || $prod == '') ? $sql .= '' : $param['prod'] = $prod;
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $param['abonneId'] = $abonneId;
( $caisseId == '0' || $caisseId == '') ? $sql .= '' : $param['caisseId'] = $caisseId;
( $produitMere == '0' || $produitMere == '') ? $sql .= '' : $param['produitMere'] = $produitMere;
// ( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
if($type !=0){
//var_dump($sql,$type );exit;
}
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
// var_dump( $type , $query->getSQL(), $type );exit;
if($type !=0){
//var_dump( $type , $query->getSQL(), $type );exit;
}
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
//var_dump($type, $query->getSQL(), $produitMere, $prod );exit;
return $query->getResult();
}
public function getRechercheCommandeAnnexe($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $prod = '0', $type=0, $nbParPage = 20, $pageActuelle = 1, $niveau = 4, $abonneId=0, $caisseId=0 , $produitMere=0 ) {
// var_dump()
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
$infoVille = $this->getStringSqlVille($niveau);
//var_dump($datedeb, $datefin);exit;
//traitement des tableaux
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
$sql = "SELECT cp.value as quantite, pr.nomProduit , c.dateCommande
FROM App\Entity\stock\Commande c ";
$sql .= " INNER JOIN c.lignecommandes l ";
$sql .= " INNER JOIN l.prixrigueur pri ";
if($nomcol!=0){
$sql .= " INNER JOIN l.fournisseur f ";
}
if($caisseId !=0)
$sql .= " INNER JOIN c.caisse cs ";
$sql .= " INNER JOIN l.produit pr ";
$sql .= " INNER JOIN c.abonne a ";
$sql .= " INNER JOIN pr.carateristiqueproduits cp ";
$sql .= " INNER JOIN cp.produitparent pp ";
/*if($prod != 1){
$sql .= " INNER JOIN l.producteur p ";
$sql .= $infoVille[0];
}else{
$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN s.ville v ";
$sql .= " INNER JOIN s.utilisateur u ";
}*/
$sql .= " WHERE c.annule != 1 and 1=1 and l.etatLigneCommande !=2 and cp.etatCaratersitiqueProduit = 1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.dateCommande >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.dateCommande <= " . " '" . $paramfin . "' " : $sql .= '';
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $sql .= ' AND a.id = :abonneId';
( $produitMere == '0' || $produitMere == '') ? $sql .= '' : $sql .= ' AND pp.id = :produitMere';
( $caisseId == '0' || $caisseId == '') ? $sql .= '' : $sql .= ' AND cs.id = :caisseId';
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND pr.id = :prod';
$sql .= ' AND c.typeCommande = :typec';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
/*if($prod != 1){
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v3.id = :ville';
}else{
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
}*/
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} else {
$sql .= ' AND c.etatCommande =2';
}
}
/** Fin critère recherche * */
$sql .= ' ORDER BY c.id DESC ';
/** debut parametres * */
$param['typec'] = $type;
( $prod == '0' || $prod == '') ? $sql .= '' : $param['prod'] = $prod;
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $param['abonneId'] = $abonneId;
( $caisseId == '0' || $caisseId == '') ? $sql .= '' : $param['caisseId'] = $caisseId;
( $produitMere == '0' || $produitMere == '') ? $sql .= '' : $param['produitMere'] = $produitMere;
// ( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
if($type !=0){
//var_dump($sql,$type );exit;
}
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
// var_dump( $type , $query->getSQL(), $type );exit;
if($type !=0){
//var_dump( $type , $query->getSQL(), $type );exit;
}
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
//var_dump($type, $query->getSQL(), $produitMere, $prod );exit;
return $query->getResult();
}
public function getStatsRechercheCommandeProducteur($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $prod = '0', $nbParPage = 20, $pageActuelle = 1) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
//var_dump($datedeb, $datefin);exit;
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}
//traitement des tableaux
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
$sql = "SELECT sum(l.quantite) as quantiteTotal, sum(l.quantiteLivre) as quantiteTotalLivre, sum(l.quantite*p.infoPrixRigueur) as montantTotal, sum(l.quantite*p.infoPrixRigueur) as montantTotalLivre
FROM App\Entity\stock\Commande c ";
$sql .= " INNER JOIN c.lignecommandes l ";
$sql .= " INNER JOIN l.prixrigueur p ";
$sql .= " INNER JOIN l.producteur f ";
$sql .= " INNER JOIN l.produit pr ";
//$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN f.utilisateur u ";
// $sql .= " INNER JOIN u.ville v ";
$sql .= " WHERE c.annule != 1 and 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.dateCommande >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.dateCommande <= " . " '" . $paramfin . "' " : $sql .= '';
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND pr.id = :prod';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} else {
$sql .= ' AND c.etatCommande =2';
}
}
/** Fin critère recherche * */
$sql .= ' ORDER BY c.id DESC ';
/** debut parametres * */
( $prod == '0' || $prod == '') ? $sql .= '' : $param['prod'] = $prod;
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
// var_dump($total);exit;
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
//var_dump( $query->getSQL());exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
//var_dump($util,$query->getSQL());exit;
return $query->getResult();
}
public function getStatsRechercheLivraison($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $nbParPage = 20, $pageActuelle = 1) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
//var_dump($datedeb, $datefin);exit;
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}
//traitement des tableaux
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
$sql = "SELECT i
FROM App\Entity\stock\InfoLivrer i ";
$sql .= " INNER JOIN i.fournisseur f ";
$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN s.ville v ";
$sql .= " WHERE 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND i.dateLivraison >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND i.dateLivraison <= " . " '" . $paramfin . "' " : $sql .= '';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
// $sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
// $sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} else {
// $sql .= ' AND c.etatCommande =2';
}
}
/** Fin critère recherche * */
// $sql .= ' ORDER BY l.id DESC ';
/** debut parametres * */
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
// var_dump($total);exit;
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
//var_dump( $query->getSQL());exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
// var_dump($query->getResult());exit;
return $query->getResult();
}
public function getStatsRechercheLivraisonMois($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $nbParPage = 20, $pageActuelle = 1,$prod=2,$niveau=4) {
// $ville = 0;
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
//var_dump($datedeb, $datefin);exit;
$infoVille = $this->getStringSqlVille($niveau);
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}
//traitement des tableaux
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
//
$sql = "SELECT SUM(i.nbreTotalLivre*pr.infoPrixRigueur) as montantTotalLivraison
FROM App\Entity\stock\InfoLivrer i ";
$sql .= " INNER JOIN i.prixrigueur pr ";
/*$sql .= " INNER JOIN i.fournisseur f ";
$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN s.ville v ";*/
if($prod != 1){
$sql .= " INNER JOIN i.livrers l ";
$sql .= " INNER JOIN l.lignecommande li ";
$sql .= " INNER JOIN li.producteur p ";
$sql .= $infoVille[0];
}else{
$sql .= " INNER JOIN i.fournisseur f ";
$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN s.ville v ";
}
$sql .= " WHERE 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND i.dateLivraison >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND i.dateLivraison <= " . " '" . $paramfin . "' " : $sql .= '';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
if($prod != 1){
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v3.id = :ville';
}else{
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
}
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
// $sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
// $sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} else {
// $sql .= ' AND c.etatCommande =2';
}
}
/** Fin critère recherche * */
// $sql .= ' ORDER BY l.id DESC ';
/** debut parametres * */
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
// var_dump($total);exit;
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
//var_dump( $query->getSQL());exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
// var_dump($query->getResult());exit;
return $query->getResult();
}
public function getStatsRechercheLivraisonQuantiteMois($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $nbParPage = 20, $pageActuelle = 1,$prod=2,$niveau=4,$abonneId=0,$caisseId=0) {
// $ville = 0;
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
$heure = " 23:59:59";
//var_dump($datedeb, $datefin);exit;
$infoVille = $this->getStringSqlVille($niveau);
$dateJour = new \DateTime();
if ($datedeb == 0 && $datefin == 0) {
$datedeb = $dateJour->format("31/12/1990 00:00:00");//$premierDate->format("d/m/Y 00:00:00");
$datefin = $dateJour->format("d/m/Y 23:59:59");
}else if ($datedeb == 1 && $datefin == 1) {
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}
//traitement des tableaux
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
//
$sql = "SELECT SUM(l.nbreLivre) as quantiteLivrer
FROM App\Entity\stock\Livrer l ";
// $sql .= " INNER JOIN i.prixrigueur pr ";
/*$sql .= " INNER JOIN i.fournisseur f ";
$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN s.ville v ";*/
//if($prod != 1){
$sql .= " INNER JOIN l.infolivrer i";
$sql .= " INNER JOIN l.lignecommande li ";
$sql .= " INNER JOIN li.produit pd ";
if($caisseId !=0)
$sql .= " INNER JOIN i.caisse cs INNER JOIN pd.abonne a ";
else
$sql .= " INNER JOIN i.abonne a ";
//$sql .= " INNER JOIN li.producteur p ";
//$sql .= $infoVille[0];
/*}else{
$sql .= " INNER JOIN i.fournisseur f ";
$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN s.ville v ";
}*/
$sql .= " WHERE 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND i.dateLivraison >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND i.dateLivraison <= " . " '" . $paramfin.$heure . "' " : $sql .= '';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
/* if($prod != 1){
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v3.id = :ville';
}else{
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
}*/
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND pd.id =:prod ';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
// $sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
// $sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} else {
// $sql .= ' AND c.etatCommande =2';
}
}
/** Fin critère recherche * */
// $sql .= ' ORDER BY l.id DESC ';
/** debut parametres * */
if($caisseId !=0){
( $caisseId == '0' || $caisseId == '') ? $sql .= '' : $sql .= ' AND cs.id = :caisseId';
( $caisseId == '0' || $caisseId == '') ? $sql .= '' : $param['caisseId'] = $caisseId;
}else{
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $sql .= ' AND a.id = :abonneId';
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $param['abonneId'] = $abonneId;
$sql .= ' AND i.caisse is null';
}
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
// ( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
( $prod == '0' || $prod == '') ? $prod .= '' : $param['prod'] = $prod;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
//var_dump($sql, $caisseId);exit;
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
//var_dump( $query->getSQL(), $caisseId, $prod);exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
// var_dump($query->getResult());exit;
return $query->getResult();
}
public function getStatsRechercheLivraisonTotal($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $nbParPage = 20, $pageActuelle = 1,$datedebchoisi=0,$prod=2,$niveau=4, $abonneId=0) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
$infoVille = $this->getStringSqlVille($niveau);
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}
//traitement des tableaux
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
if($datedebchoisi != 0){
$objetDateDebDefault = \DateTime::createFromFormat("d/m/Y",$datedeb);
$objetDateDeb = \DateTime::createFromFormat('d/m/Y',$datedebchoisi);
// var_dump($datedebchoisi, $objetDateDebDefault,$objetDateDeb);exit;
if( $objetDateDeb<$objetDateDebDefault){
$paramdeb = $objetDateDebDefault->format("Y-m-d") ;
}else{
$paramdeb = $objetDateDeb->format("Y-m-d") ;
}
}
$sql = "SELECT SUM(i.nbreTotalLivre*pr.infoPrixRigueur) as montantTotalLivraison
FROM App\Entity\stock\InfoLivrer i ";
//$sql .= " INNER JOIN i.livrers l ";
$sql .= " INNER JOIN i.prixrigueur pr ";
$sql .= " INNER JOIN i.fournisseur f ";
$sql .= " INNER JOIN i.abonne a ";
/*if($prod != 1){
$sql .= " INNER JOIN i.livrers l ";
$sql .= " INNER JOIN l.lignecommande li ";
$sql .= " INNER JOIN i.fournisseur f ";
$sql .= " INNER JOIN li.producteur p ";
$sql .= $infoVille[0];
}else{
$sql .= " INNER JOIN i.fournisseur f ";
$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN s.ville v ";
}*/
$sql .= " WHERE 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND i.dateLivraison >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND i.dateLivraison <= " . " '" . $paramfin . "' " : $sql .= '';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $sql .= ' AND a.id =:abonneId';
/*if($prod != 1){
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v3.id = :ville';
}else{
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
}*/
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $param['abonneId'] = $abonneId;
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
// $sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
// $sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} else {
// $sql .= ' AND c.etatCommande =2';
}
}
/** Fin critère recherche * */
// $sql .= ' ORDER BY l.id DESC ';
//var_dump($sql);exit;
/** debut parametres * */
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
// ( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
// var_dump($total);exit;
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
//var_dump( $query->getSQL());exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
// var_dump($query->getSQL());exit;
$montantTotal = array();
if($datedebchoisi != 0){
$objetDateDebDefault = \DateTime::createFromFormat("d/m/Y",$datedeb);
$objetDateDeb = \DateTime::createFromFormat("d/m/Y",$datedebchoisi);
if( $objetDateDeb<$objetDateDebDefault){
$totalMoisAvantMisAuPoint = $this->getRechercheSoldeInfoLivrer($nomcol, $ville, $datedebchoisi, $datedeb,0);
}else{
$totalMoisAvantMisAuPoint[0]["montantTotalLivraison"] =0;
}
}else{
$totalMoisAvantMisAuPoint = $this->getRechercheSoldeInfoLivrer($nomcol, $ville, "01/05/2015", "01/09/2017",0);
}
$totalSecondEncours = $query->getResult();
// var_dump($totalSecondEncours[0]["montantTotalLivraison"],$totalMoisAvantMisAuPoint[0]["montantTotalLivraison"],'|');
$montantTotal[0]["montantTotalLivraison"] = $totalSecondEncours[0]["montantTotalLivraison"]+$totalMoisAvantMisAuPoint[0]["montantTotalLivraison"] ;
return $montantTotal ;
}
public function getStatsRechercheLivraisonNewTotal($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $nbParPage = 20, $pageActuelle = 1,$datedebchoisi=0,$prod=2,$niveau=4) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
$infoVille = $this->getStringSqlVille($niveau);
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}
//traitement des tableaux
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
if($datedebchoisi != 0){
$objetDateDebDefault = \DateTime::createFromFormat("d/m/Y",$datedeb);
$objetDateDeb = \DateTime::createFromFormat('d/m/Y',$datedebchoisi);
// var_dump($datedebchoisi, $objetDateDebDefault,$objetDateDeb);exit;
if( $objetDateDeb<$objetDateDebDefault){
$paramdeb = $objetDateDebDefault->format("Y-m-d") ;
}else{
$paramdeb = $objetDateDeb->format("Y-m-d") ;
}
}
$sql = "SELECT SUM(i.nbreTotalLivre*pr.infoPrixRigueur) as montantTotalLivraison
FROM App\Entity\stock\InfoLivrer i ";
//$sql .= " INNER JOIN i.livrers l ";
$sql .= " INNER JOIN i.prixrigueur pr ";
if($prod != 1){
$sql .= " INNER JOIN i.livrers l ";
$sql .= " INNER JOIN l.lignecommande li ";
$sql .= " INNER JOIN i.fournisseur f ";
$sql .= " INNER JOIN li.producteur p ";
$sql .= $infoVille[0];
}else{
$sql .= " INNER JOIN i.fournisseur f ";
$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN s.ville v ";
}
$sql .= " WHERE 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND i.dateLivraison >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND i.dateLivraison <= " . " '" . $paramfin . "' " : $sql .= '';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
if($prod != 1){
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v3.id = :ville';
}else{
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
}
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
// $sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
// $sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} else {
// $sql .= ' AND c.etatCommande =2';
}
}
/** Fin critère recherche * */
// $sql .= ' ORDER BY l.id DESC ';
//var_dump($sql);exit;
/** debut parametres * */
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
// var_dump($total);exit;
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
//var_dump( $query->getSQL());exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
// var_dump($query->getSQL());exit;
$montantTotal = array();
if($datedebchoisi != 0){
$objetDateDebDefault = \DateTime::createFromFormat("d/m/Y",$datedeb);
$objetDateDeb = \DateTime::createFromFormat("d/m/Y",$datedebchoisi);
if( $objetDateDeb<$objetDateDebDefault){
$totalMoisAvantMisAuPoint = $this->getRechercheSoldeInfoLivrer($nomcol, $ville, $datedebchoisi, $datedeb,0);
}else{
$totalMoisAvantMisAuPoint[0]["montantTotalLivraison"] =0;
}
}else{
$totalMoisAvantMisAuPoint = $this->getRechercheSoldeInfoLivrer($nomcol, $ville, "01/05/2015", "01/09/2017",0);
}
$totalSecondEncours = $query->getResult();
// var_dump($totalSecondEncours[0]["montantTotalLivraison"],$totalMoisAvantMisAuPoint[0]["montantTotalLivraison"],'|');
$montantTotal[0]["montantTotalLivraison"] = $totalSecondEncours[0]["montantTotalLivraison"]+$totalMoisAvantMisAuPoint[0]["montantTotalLivraison"] ;
return $montantTotal ;
}
public function getSumQuantiteLivraisonTotal($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $nbParPage = 20, $pageActuelle = 1,$datedebchoisi=0, $prod= 1,$abonneId=0) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = "01/01/2014";//$premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}
//traitement des tableaux
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
//var_dump($paramdeb,$paramfin);exit;
$sql = "SELECT SUM(l.nbreLivre) as totalLivraison, SUM(i.nbreSaisie) as totalLivraisonSaisie, SUM(l.nbreLivre * pr.infoPrixRigueur) as montantTotalLivre
FROM App\Entity\stock\InfoLivrer i ";
$sql .= " INNER JOIN i.livrers l ";
$sql .= " INNER JOIN l.lignecommande li ";
$sql .= " INNER JOIN i.fournisseur f ";
$sql .= " INNER JOIN i.abonne a ";
$sql .= " INNER JOIN i.prixrigueur pr ";
/*if($prod != 1){
$sql .= " INNER JOIN i.fournisseur f ";
$sql .= " INNER JOIN li.producteur p ";
$sql .= " INNER JOIN i.prixrigueur pr ";
//$sql .= $infoVille[0];
}else{
$sql .= " INNER JOIN i.fournisseur f ";
$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN s.ville v ";
$sql .= " INNER JOIN i.prixrigueur pr ";
}*/
$sql .= " WHERE 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND i.dateLivraison >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND i.dateLivraison <= " . " '" . $paramfin . "' " : $sql .= '';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
//( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
// $sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
// $sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} else {
// $sql .= ' AND c.etatCommande =2';
}
}
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $sql .= ' AND a.id =:abonneId';
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $param['abonneId'] = $abonneId;
/** Fin critère recherche * */
// $sql .= ' ORDER BY l.id DESC ';
/** debut parametres * */
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
//( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
//var_dump($sql);exit;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
// var_dump($total);exit;
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
//var_dump( $query->getSQL());exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
// var_dump($query->getSQL());exit;
$montantTotal = array();
$totalSecondEncours = $query->getResult();
// $montantTotal[0]["montantTotalLivraison"] = $totalSecondEncours[0]["mont$totalLivreantTotalLivraison"]+$totalMoisAvantMisAuPoint[0]["montantTotalLivraison"] ;
return $totalSecondEncours ;
}
public function getRechercheSoldeInfoLivrer($four, $ville, $datedeb, $datefin,$prix)
{
$param =array();
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
//var_dump($paramdeb,$paramfin);exit;
$sql = "SELECT SUM(l.nbreLivre*p.infoPrixRigueur) as montantTotalLivraison
FROM App\Entity\stock\InfoLivrer i ";
$sql .= " INNER JOIN i.livrers l ";
$sql .= " INNER JOIN l.lignecommande li ";
$sql .= " INNER JOIN li.prixrigueur p ";
$sql .= " INNER JOIN i.fournisseur f ";
$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN s.ville v ";
$sql .= " WHERE 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND i.dateLivraison >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND i.dateLivraison < " . " '" . $paramfin . "' " : $sql .= '';
//var_dump($four);exit;
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $four == '0' || $four == '') ? $sql .= '' : $sql .= ' AND f.id = :four';
( $prix == '0' || $prix == '') ? $sql .= '' : $sql .= ' AND p.id = :prix';
// var_dump($sql());exit;
( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $four == '0' || $four == '') ? $sql .= '' : $param['four'] = $four;
( $prix == '0' || $prix == '') ? $sql .= '' : $param['prix'] = $prix;
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
//var_dump($query->getSql());exit;
return $query->getResult();
}
public function getStatsInfoLivraisonCommande($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $nbParPage = 20, $pageActuelle = 1) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
//var_dump($datedeb, $datefin);exit;
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}
//traitement des tableaux
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
$sql = "SELECT sum(i.nbreTotalLivre) as quantiteTotalLivre, sum(i.nbreTotalLivre*p.infoPrixRigueur) as montantTotalLivre
FROM App\Entity\stock\LigneCommande l ";
//$sql .= " INNER JOIN c.lignecommandes l ";
$sql .= " INNER JOIN l.prixrigueur p ";
$sql .= " INNER JOIN l.fournisseur f ";
$sql .= " INNER JOIN l.livrers li ";
$sql .= " INNER JOIN li.infolivrer i ";
$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN s.utilisateur u ";
$sql .= " INNER JOIN s.ville v ";
$sql .= " WHERE 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND i.dateLivraison >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND i.dateLivraison <= " . " '" . $paramfin . "' " : $sql .= '';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} else {
$sql .= ' AND c.etatCommande =2';
}
}
/** Fin critère recherche * */
// $sql .= ' ORDER BY c.id DESC ';
/** debut parametres * */
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
// var_dump($total);exit;
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
//var_dump( $query->getSQL());exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
//var_dump($util,$query->getSQL());exit;
return $query->getResult();
}
public function getApiListeRechercheCommande($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $typeLimite = 0, $nbParPage = 20, $pageActuelle = 1) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}
//traitement des tableaux
//var_dump($util);exit;
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
//var_dump($datedeb, $datefin);exit;
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
//var_dump($paramdeb,$paramfin);exit;
$sql = "SELECT DISTINCT c.id, f.nomFournisseur, l.quantite as quantiteReelle, l.quantiteLivre as quantitePesee, l.montantHt as montant, e.nomEntrepot, v.nomVille, u.nom as codeGenere
FROM App\Entity\stock\Commande c ";
$sql .= " INNER JOIN c.lignecommandes l ";
$sql .= " INNER JOIN l.livrers li ";
$sql .= " INNER JOIN li.infolivrer i ";
$sql .= " INNER JOIN li.entrepot e ";
$sql .= " INNER JOIN l.fournisseur f ";
$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN s.utilisateur u ";
$sql .= " INNER JOIN s.ville v ";
$sql .= " WHERE c.annule != 1 and 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.dateCommande >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.dateCommande <= " . " '" . $paramfin . "' " : $sql .= '';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} elseif ($silivre == 3) {
$sql .= ' AND c.etatCommande =2';
} elseif ($silivre == 4) {
$sql .= ' AND l.quantiteLivre !=0';
} else {
$sql .= ' AND (l.quantiteLivre !=0 AND c.etatCommande !=2) or l.quantiteLivre =0 ';
}
}
/** Fin critère recherche * */
$sql .= ' ORDER BY c.id DESC ';
//var_dump($silivre,$sql);exit;
/** debut parametres * */
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
// var_dump($total);exit;
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
if ($typeLimite == 1) {
$query->setMaxResults(5);
}
// var_dump( $query->getSQL());exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
return $query->getResult();
}
public function getApiDetailFournisseurCommande($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $typeLimite = 0, $nbParPage = 20, $pageActuelle = 1) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}
//traitement des tableaux
//var_dump($util);exit;
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
//var_dump($datedeb, $datefin);exit;
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
//var_dump($paramdeb,$paramfin);exit;
$sql = "SELECT DISTINCT c.id,p.id as prodId, f.nomFournisseur,ut.nom as nomProducteur, SUM(i.nbreSaisie) as quantiteReelle, SUM(l.quantiteLivre) as quantitePesee, SUM(l.montantHt) as montant, e.nomEntrepot, v.nomVille, u.nom as codeGenere, p.codeProd, p.urlImage, sa.superficie as valSurface
FROM App\Entity\stock\Commande c ";
$sql .= " INNER JOIN c.lignecommandes l ";
$sql .= " INNER JOIN l.livrers li ";
$sql .= " INNER JOIN li.infolivrer i ";
$sql .= " INNER JOIN i.producteurlivraisons pl ";
$sql .= " INNER JOIN pl.producteur p ";
$sql .= " INNER JOIN p.utilisateur ut ";
$sql .= " INNER JOIN li.entrepot e ";
$sql .= " INNER JOIN l.fournisseur f ";
$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN s.utilisateur u ";
$sql .= " INNER JOIN s.ville v ";
$sql .= " INNER JOIN p.surfaceannees sa ";
//$sql .= " INNER JOIN sa.surface sf ";
$sql .= " WHERE c.annule != 1 and 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.dateCommande >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.dateCommande <= " . " '" . $paramfin . "' " : $sql .= '';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND p.id = :nomcol';
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} elseif ($silivre == 3) {
$sql .= ' AND c.etatCommande =2';
} elseif ($silivre == 4) {
$sql .= ' AND l.quantiteLivre !=0';
} else {
$sql .= ' AND (l.quantiteLivre !=0 AND c.etatCommande !=2) or l.quantiteLivre =0 ';
}
}
/** Fin critère recherche * */
$sql .= ' GROUP BY p.id';
//var_dump($silivre,$sql);exit;
/** debut parametres * */
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
// var_dump($total);exit;
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
// var_dump( $query->getSQL());exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
return $query->getResult();
}
public function getApiFournisseurSemence($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $prod=0, $typeLimite = 0, $nbParPage = 20, $pageActuelle = 1) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
/* if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
} */
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
//var_dump($datedeb, $datefin);exit;
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
$sql = "SELECT DISTINCT c.id, c.dateCommande as dateSemence,c.etatCommande as etatSemence, c.refBonCommande as refSemence, f.nomFournisseur,
l.quantite as quantiteReelle, l.quantiteLivre as quantitePaye,
l.montantHt as montant,
u.nom as codeGenere, ac.infoAnneeCampagne,pr.id as idProd ,c.codeGenere, ac.id as idAnnee
FROM App\Entity\stock\Commande c ";
$sql .= " INNER JOIN c.utilisateur u ";
$sql .= " INNER JOIN c.lignecommandes l ";
$sql .= " INNER JOIN l.producteur pr ";
$sql .= " INNER JOIN l.fournisseur f ";
$sql .= " INNER JOIN c.anneecampagne ac ";
//$sql .= " INNER JOIN f.setrouvers s ";
//$sql .= " INNER JOIN s.ville v ";
$sql .= " WHERE c.annule != 1 and 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.dateCommande >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.dateCommande <= " . " '" . $paramfin . "' " : $sql .= '';
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND pr.id = :prod';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} elseif ($silivre == 3) {
$sql .= ' AND c.etatCommande =2';
} elseif ($silivre == 4) {
$sql .= ' AND l.quantiteLivre !=0';
} else {
$sql .= ' AND (l.quantiteLivre !=0 AND c.etatCommande !=2) or l.quantiteLivre =0 ';
}
}
/** Fin critère recherche * */
$sql .= ' ORDER BY c.id DESC ';
//var_dump($silivre,$sql);exit;
/** debut parametres * */
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
( $prod == '0' || $prod == '') ? $sql .= '' : $param['prod'] = $prod;
( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
//var_dump($sql);exit;
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
if ($typeLimite == 1) {
$query->setMaxResults(5);
}
// var_dump( $query->getSQL());exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
return $query->getResult();
}
public function getApiFournisseurProducteurSemence($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $prod=0, $typeLimite = 0, $nbParPage = 20, $pageActuelle = 1) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
/* if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
} */
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
//var_dump($datedeb, $datefin);exit;
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
$sql = "SELECT DISTINCT c.id, c.dateCommande as dateSemence,c.etatCommande as etatSemence, c.refBonCommande as refSemence, f.nomFournisseur,
l.quantite as quantiteReelle, l.quantiteLivre as quantitePaye,
l.montantHt as montant, v.nomVille,
u.nom as codeGenere, ac.infoAnneeCampagne,pr.id as idProd ,c.codeGenere, ac.id as idAnnee
FROM App\Entity\stock\Commande c ";
$sql .= " INNER JOIN c.lignecommandes l ";
$sql .= " INNER JOIN l.producteur pr ";
$sql .= " INNER JOIN pr.fournisseurproducteurs fp ";
$sql .= " INNER JOIN fp.fournisseur f ";
$sql .= " INNER JOIN c.anneecampagne ac ";
$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN s.utilisateur u ";
$sql .= " INNER JOIN s.ville v ";
$sql .= " WHERE c.annule != 1 and 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.dateCommande >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.dateCommande <= " . " '" . $paramfin . "' " : $sql .= '';
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND pr.id = :prod';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} elseif ($silivre == 3) {
$sql .= ' AND c.etatCommande =2';
} elseif ($silivre == 4) {
$sql .= ' AND l.quantiteLivre !=0';
} else {
$sql .= ' AND (l.quantiteLivre !=0 AND c.etatCommande !=2) or l.quantiteLivre =0 ';
}
}
/** Fin critère recherche * */
$sql .= ' ORDER BY c.id DESC ';
//var_dump($silivre,$sql);exit;
/** debut parametres * */
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
( $prod == '0' || $prod == '') ? $sql .= '' : $param['prod'] = $prod;
( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
// var_dump($total);exit;
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
if ($typeLimite == 1) {
$query->setMaxResults(5);
}
// var_dump( $query->getSQL());exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
return $query->getResult();
}
public function getApiNewFournisseurProducteurSemence($nomcol, $datefin, $datedeb, $tabVille, $util, $silivre, $numcom, $prod=0, $typeLimite = 0, $nbParPage = 20, $pageActuelle = 1,$niveau=4, $abonneId=0) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
/* if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
} */
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
//var_dump($datedeb, $datefin);exit;
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
$infoVille = $this->getStringSqlVille($niveau);
$sql = "SELECT DISTINCT c.id, c.dateCommande as dateSemence,c.etatCommande as etatSemence, c.refBonCommande as refSemence, f.nomFournisseur,
l.quantite as quantiteReelle, l.quantiteLivre as quantitePaye,
l.montantHt as montant, v3.nomVille,
u.nom as codeGenere, ac.infoAnneeCampagne,p.id as idProd ,c.codeGenere, ac.id as idAnnee
FROM App\Entity\stock\Commande c ";
$sql .= " INNER JOIN c.lignecommandes l ";
$sql .= " INNER JOIN l.producteur p ";
$sql .= " INNER JOIN l.fournisseur f ";
$sql .= " INNER JOIN c.anneecampagne ac ";
$sql .= " INNER JOIN p.utilisateur u ";
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $sql .= ' INNER JOIN c.abonne a ';
$sql .= $infoVille[0];
$sql .= " WHERE c.annule != 1 and 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.dateCommande >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.dateCommande <= " . " '" . $paramfin . "' " : $sql .= '';
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $sql .= ' AND a.id = :abonneId';
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND p.id = :prod';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
if($tabVille !=0){
if($prod != 1){
$i=0;
foreach($tabVille as $uneVille){
if($i == 0){
$sql .= " AND v3.id = :ville".$uneVille->getVille()->getId()."";
//var_dump($uneVille->getId());
}else{
$sql .= " OR v3.id = :ville".$uneVille->getVille()->getId()."";
}
$i++;
//$tabProduitUser[] = $unInfoProduit->getId();
}
//( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v3.id = :ville';
}else{
( $tabVille == '0' || $tabVille == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
}
}
//var_dump($niveau, $sql);exit;
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} elseif ($silivre == 3) {
$sql .= ' AND c.etatCommande =2';
} elseif ($silivre == 4) {
$sql .= ' AND l.quantiteLivre !=0';
} else {
$sql .= ' AND (l.quantiteLivre !=0 AND c.etatCommande !=2) or l.quantiteLivre =0 ';
}
}
/** Fin critère recherche * */
$sql .= ' ORDER BY c.id DESC ';
//var_dump($silivre,$sql);exit;
/** debut parametres * */
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
( $prod == '0' || $prod == '') ? $sql .= '' : $param['prod'] = $prod;
( $abonneId == '0' || $abonneId == '') ? $sql .= '' : $param['abonneId'] = $abonneId;
// ( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
if($tabVille !=0){
if($prod != 1){
foreach($tabVille as $uneVille){
$param["ville".$uneVille->getVille()->getId().""] = $uneVille->getVille()->getId();
}
}else{
( $tabVille == '0' || $tabVille == '') ? $sql .= '' : $param['ville'] = $tabVille;
}
}
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
// var_dump($total);exit;
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
if ($typeLimite == 1) {
$query->setMaxResults(5);
}
// var_dump( $query->getSQL());exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
return $query->getResult();
}
public function getApiFournisseurSumSemence($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $prod=0, $typeLimite = 0, $nbParPage = 20, $pageActuelle = 1) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
/* if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
} */
//traitement des tableaux
//var_dump($util);exit;
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
//var_dump($datedeb, $datefin);exit;
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
//var_dump($paramdeb,$paramfin);exit;
$sql = "SELECT SUM(l.quantiteLivre) as quantiteTotale, f.id,
l.quantite as quantiteReelle, l.quantiteLivre as quantitePesee,
l.montantHt as montant, v.nomVille,
u.nom as codeGenere, ac.infoAnneeCampagne
FROM App\Entity\stock\Commande c ";
$sql .= " INNER JOIN c.lignecommandes l ";
$sql .= " INNER JOIN l.producteur pr ";
$sql .= " INNER JOIN l.fournisseur f ";
$sql .= " INNER JOIN c.anneecampagne ac ";
$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN s.utilisateur u ";
$sql .= " INNER JOIN s.ville v ";
$sql .= " WHERE c.annule != 1 and 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.dateCommande >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.dateCommande <= " . " '" . $paramfin . "' " : $sql .= '';
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND pr.id = :prod';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} elseif ($silivre == 3) {
$sql .= ' AND c.etatCommande =2';
} elseif ($silivre == 4) {
$sql .= ' AND l.quantiteLivre !=0';
} else {
$sql .= ' AND (l.quantiteLivre !=0 AND c.etatCommande !=2) or l.quantiteLivre =0 ';
}
}
/** Fin critère recherche * */
$sql .= ' GROUP BY f.id ORDER BY c.id DESC ';
//var_dump($silivre,$sql);exit;
/** debut parametres * */
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
( $prod == '0' || $prod == '') ? $sql .= '' : $param['prod'] = $prod;
( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
// var_dump($total);exit;
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
if ($typeLimite == 1) {
$query->setMaxResults(5);
}
// var_dump( $query->getSQL());exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
return $query->getResult();
}
public function getLigneCommandeOperation($idProd, $idAnnee) {
$query = $this->_em->createQuery(
'SELECT l
FROM App\Entity\stock\LigneCommande l
INNER JOIN l.commande c
INNER JOIN c.anneecampagne a
INNER JOIN l.producteur p
WHERE p.id = :idProd and a.id =:idAnnee'
)->setParameters(array('idProd'=>$idProd, 'idAnnee'=>$idAnnee));
return $query->getResult();
}
public function getApiFournisseurSumSemenceByAnnee($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $prod, $anneeCampagne) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
/* if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
} */
//traitement des tableaux
//var_dump($util);exit;
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
//var_dump($datedeb, $datefin);exit;
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
//var_dump($paramdeb,$paramfin);exit;
$sql = "SELECT pr.id, c.codeCommande, SUM(l.quantite) as quantiteTotal, l.montantHt, u.nom, ac.infoAnneeCampagne
FROM App\Entity\stock\Commande c ";
$sql .= " INNER JOIN c.lignecommandes l ";
$sql .= " INNER JOIN l.producteur pr ";
$sql .= " INNER JOIN c.fournisseur f ";
$sql .= " INNER JOIN c.anneecampagne ac ";
$sql .= " INNER JOIN pr.utilisateur u ";
//$sql .= " INNER JOIN s.ville v ";
$sql .= " WHERE c.annule != 1 and 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.dateCommande >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.dateCommande <= " . " '" . $paramfin . "' " : $sql .= '';
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND pr.id = :prod';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
( $anneeCampagne == '0' || $anneeCampagne == '') ? $sql .= '' : $sql .= ' AND ac.id = :idAnnee';
// ( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} elseif ($silivre == 3) {
$sql .= ' AND c.etatCommande =2';
} elseif ($silivre == 4) {
$sql .= ' AND l.quantiteLivre !=0';
} else {
$sql .= ' AND (l.quantiteLivre !=0 AND c.etatCommande !=2) or l.quantiteLivre =0 ';
}
}
/** Fin critère recherche * */
$sql .= ' GROUP BY pr.id ';
//var_dump($sql);exit;
// var_dump($sql);exit;
//var_dump($silivre,$sql);exit;
/** debut parametres * */
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
( $prod == '0' || $prod == '') ? $sql .= '' : $param['prod'] = $prod;
( $anneeCampagne == '0' || $anneeCampagne == '') ? $sql .= '' : $param['idAnnee'] = $anneeCampagne;
// ( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
// var_dump($query->getSQL());exit;
return $query->getResult();
}
public function getApiFournisseurSumSemenceByAnneeDetail($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $prod, $anneeCampagne,$niveau=4,$tabVille) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
/* if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
} */
//traitement des tableaux
//var_dump($util);exit;
//heure debut
$infoVille = $this->getStringSqlVille($niveau);
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
//var_dump($datedeb, $datefin);exit;
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
//var_dump($paramdeb,$paramfin);exit;
$sql = "SELECT p.id, c.codeCommande, SUM(l.quantite) as quantiteTotal, l.montantHt, u.nom, ac.infoAnneeCampagne
FROM App\Entity\stock\Commande c ";
$sql .= " INNER JOIN c.lignecommandes l ";
$sql .= " INNER JOIN l.producteur p";
$sql .= " INNER JOIN c.fournisseur f ";
$sql .= " INNER JOIN c.anneecampagne ac ";
$sql .= " INNER JOIN p.utilisateur u ";
$sql .= $infoVille[0];
$sql .= " WHERE c.annule != 1 and 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.dateCommande >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.dateCommande <= " . " '" . $paramfin . "' " : $sql .= '';
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND p.id = :prod';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
( $anneeCampagne == '0' || $anneeCampagne == '') ? $sql .= '' : $sql .= ' AND ac.id = :idAnnee';
// ( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
//( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= $infoVille[1];
$i = 0;
if($tabVille != 0){
foreach($tabVille as $uneVille){
if($i == 0){
$sql .= " AND ( v".$niveau.".id = :ville".$uneVille->getVille()->getId()."";
}else{
$sql .= " OR v".$niveau.".id = :ville".$uneVille->getVille()->getId()."";
}
$i++;
//$tabProduitUser[] = $unInfoProduit->getId();
}
$sql .= ")";
}
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} elseif ($silivre == 3) {
$sql .= ' AND c.etatCommande =2';
} elseif ($silivre == 4) {
$sql .= ' AND l.quantiteLivre !=0';
} else {
$sql .= ' AND (l.quantiteLivre !=0 AND c.etatCommande !=2) or l.quantiteLivre =0 ';
}
}
/** Fin critère recherche * */
$sql .= ' GROUP BY p.id ';
//$sql .= ' ORDER BY p.id ';
//var_dump($ville,$sql);exit;
//var_dump($sql);exit;
//var_dump($silivre,$sql);exit;
/** debut parametres * */
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
( $prod == '0' || $prod == '') ? $sql .= '' : $param['prod'] = $prod;
( $anneeCampagne == '0' || $anneeCampagne == '') ? $sql .= '' : $param['idAnnee'] = $anneeCampagne;
// ( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
//( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
if($tabVille != 0){
foreach($tabVille as $uneVille){
//$tabProduitUser[] = $unInfoProduit->getId();
$param["ville".$uneVille->getVille()->getId().""] = $uneVille->getVille()->getId();
}
}
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
// var_dump($query->getSQL());exit;
return $query->getResult();
}
public function getStatsRechercheLivraisonTotalProducteur($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $nbParPage = 20, $pageActuelle = 1,$datedebchoisi=0) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}
//traitement des tableaux
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
if($datedebchoisi != 0){
$objetDateDebDefault = \DateTime::createFromFormat("d/m/Y",$datedeb);
$objetDateDeb = \DateTime::createFromFormat('d/m/Y',$datedebchoisi);
// var_dump($datedebchoisi, $objetDateDebDefault,$objetDateDeb);exit;
if( $objetDateDeb<$objetDateDebDefault){
$paramdeb = $objetDateDebDefault->format("Y-m-d") ;
}else{
$paramdeb = $objetDateDeb->format("Y-m-d") ;
}
}
$sql = "SELECT SUM(i.nbreTotalLivre*p.infoPrixRigueur) as montantTotalLivraison
FROM App\Entity\stock\InfoLivrer i ";
$sql .= " INNER JOIN i.livrers l ";
$sql .= " INNER JOIN i.prixrigueur p ";
$sql .= " INNER JOIN l.lignecommande li ";
$sql .= " INNER JOIN li.producteur f ";
$sql .= " INNER JOIN f.utilisateur u ";
$sql .= " INNER JOIN u.ville v ";
$sql .= " WHERE 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND i.dateLivraison >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND i.dateLivraison <= " . " '" . $paramfin . "' " : $sql .= '';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
// $sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
// $sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} else {
// $sql .= ' AND c.etatCommande =2';
}
}
/** Fin critère recherche * */
// $sql .= ' ORDER BY l.id DESC ';
// var_dump($sql);exit;
/** debut parametres * */
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
// var_dump($total);exit;
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
// var_dump( $query->getSQL());exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
// var_dump($query->getSQL());exit;
$montantTotal = array();
if($datedebchoisi != 0){
$objetDateDebDefault = \DateTime::createFromFormat("d/m/Y",$datedeb);
$objetDateDeb = \DateTime::createFromFormat("d/m/Y",$datedebchoisi);
if( $objetDateDeb<$objetDateDebDefault){
$totalMoisAvantMisAuPoint = $this->getRechercheSoldeInfoLivrer($nomcol, $ville, $datedebchoisi, $datedeb,0);
}else{
$totalMoisAvantMisAuPoint[0]["montantTotalLivraison"] =0;
}
}else{
$totalMoisAvantMisAuPoint = $this->getRechercheSoldeInfoLivrer($nomcol, $ville, "01/05/2015", "01/09/2017",0);
}
$totalSecondEncours = $query->getResult();
// var_dump($totalSecondEncours[0]["montantTotalLivraison"],$totalMoisAvantMisAuPoint[0]["montantTotalLivraison"],'|');
$montantTotal[0]["montantTotalLivraison"] = $totalSecondEncours[0]["montantTotalLivraison"]+$totalMoisAvantMisAuPoint[0]["montantTotalLivraison"] ;
return $montantTotal ;
}
public function getSumQuantiteLivraisonTotalProducteur($nomcol, $datefin, $datedeb, $ville, $util, $silivre, $numcom, $nbParPage = 20, $pageActuelle = 1,$datedebchoisi=0) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = "01/01/2014";//$premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}
//traitement des tableaux
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
//var_dump($paramdeb,$paramfin);exit;
$sql = "SELECT SUM(l.nbreLivre) as totalLivraison, SUM(l.nbreLivre*p.infoPrixRigueur) as montantTotalLivraison
FROM App\Entity\stock\InfoLivrer i ";
$sql .= " INNER JOIN i.livrers l ";
$sql .= " INNER JOIN i.prixrigueur p ";
$sql .= " INNER JOIN l.lignecommande li ";
$sql .= " INNER JOIN li.producteur f ";
$sql .= " INNER JOIN f.utilisateur u ";
$sql .= " INNER JOIN u.ville v ";
$sql .= " WHERE 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND i.dateLivraison >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND i.dateLivraison <= " . " '" . $paramfin . "' " : $sql .= '';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
// $sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
// $sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} else {
// $sql .= ' AND c.etatCommande =2';
}
}
/** Fin critère recherche * */
// $sql .= ' ORDER BY l.id DESC ';
/** debut parametres * */
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
// var_dump($total);exit;
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
//var_dump( $query->getSQL());exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
// var_dump($query->getSQL());exit;
$montantTotal = array();
$totalSecondEncours = $query->getResult();
// $montantTotal[0]["montantTotalLivraison"] = $totalSecondEncours[0]["mont$totalLivreantTotalLivraison"]+$totalMoisAvantMisAuPoint[0]["montantTotalLivraison"] ;
return $totalSecondEncours ;
}
public function getStatsRechercheCommandeCapitalisation($nomcol, $datefin, $datedeb, $tabVille, $util, $silivre, $numcom, $prod = '0', $nbParPage = 20, $pageActuelle = 1, $niveau = 4) {
$param = array();
$datedebarray = array();
$datefinarray = array();
$nbTotal = 10000;
$infoVille = $this->getStringSqlVille($niveau);
//var_dump($datedeb, $datefin);exit;
if ($datedeb == 0 && $datefin == 0) {
$dateJour = new \DateTime();
$premierDate = $this->dateDuPremierDuMois($dateJour);
$datedeb = $premierDate->format("d/m/Y");
$dateMoi = $premierDate->add(new DateInterval('P1M'));
$datefin = $dateMoi->format("d/m/Y");
}
//traitement des tableaux
//heure debut
$datedebarray = $this->traiterDateFormat($datedeb);
$datefinarray = $this->traiterDateFormat($datefin);
$paramdeb = implode("-", $datedebarray);
$paramfin = implode("-", $datefinarray);
$sql = "SELECT sum(l.quantite) as quantiteTotal, sum(l.quantiteLivre) as quantiteTotalLivre, sum(c.montantCommande) as montantTotal, sum(l.quantiteLivre*pri.infoPrixRigueur) as montantTotalLivre , sum(l.quantite*pri.infoPrixRigueur) as montantSemence
FROM App\Entity\stock\Commande c ";
$sql .= " INNER JOIN c.lignecommandes l ";
$sql .= " INNER JOIN l.prixrigueur pri ";
$sql .= " INNER JOIN l.fournisseur f ";
$sql .= " INNER JOIN l.produit pr ";
if($prod != 1){
$sql .= " INNER JOIN l.producteur p ";
$sql .= $infoVille[0];
}else{
$sql .= " INNER JOIN f.setrouvers s ";
$sql .= " INNER JOIN s.ville v ";
$sql .= " INNER JOIN s.utilisateur u ";
}
$sql .= " WHERE c.annule != 1 and 1=1 ";
/** debut critère recherche * */
// ( ($deb == null) || ($deb == 0) )? $sql.="' : $sql.=' AND o.dateValeur >= :deb and o.dateValeur <= :fin ';
( $datedeb != 0 && $datedeb != "" ) ? $sql .= " AND c.dateCommande >= " . " '" . $paramdeb . "' " : $sql .= '';
( $datefin != 0 && $datefin != "" ) ? $sql .= " AND c.dateCommande <= " . " '" . $paramfin . "' " : $sql .= '';
if($tabVille !=0){
if($prod != 1){
$i=0;
foreach($tabVille as $uneVille){
if($i == 0){
$sql .= " AND v3.id = :ville".$uneVille->getVille()->getId()."";
//var_dump($uneVille->getId());
}else{
$sql .= " OR v3.id = :ville".$uneVille->getVille()->getId()."";
}
$i++;
//$tabProduitUser[] = $unInfoProduit->getId();
}
//( $ville == '0' || $ville == '') ? $sql .= '' : $sql .= ' AND v3.id = :ville';
}else{
( $tabVille == '0' || $tabVille == '') ? $sql .= '' : $sql .= ' AND v.id = :ville';
}
}
( $prod == '0' || $prod == '') ? $sql .= '' : $sql .= ' AND pr.id = :prod';
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $sql .= ' AND f.id = :nomcol';
( $util == '0' || $util == '') ? $sql .= '' : $sql .= ' AND u.id =:util ';
( $numcom == '0' || $numcom == '') ? $sql .= '' : $sql .= ' AND c.codeCommande = :numcom';
if ($silivre == '0' || $silivre == '') {
} else {
if ($silivre == 1) {
$sql .= ' AND l.quantiteLivre =0';
} elseif ($silivre == 2) {
$sql .= ' AND l.quantiteLivre !=0 AND c.etatCommande !=2 ';
} else {
$sql .= ' AND c.etatCommande =2';
}
}
/** Fin critère recherche * */
$sql .= ' ORDER BY c.id DESC ';
/** debut parametres * */
( $prod == '0' || $prod == '') ? $sql .= '' : $param['prod'] = $prod;
( $nomcol == '0' || $nomcol == '') ? $sql .= '' : $param['nomcol'] = $nomcol;
//( $ville == '0' || $ville == '') ? $sql .= '' : $param['ville'] = $ville;
( $util == '0' || $util == '') ? $sql .= '' : $param['util'] = $util;
($numcom == '0' || $numcom == '') ? $sql .= '' : $param['numcom'] = $numcom;
if($tabVille !=0){
if($prod != 1){
foreach($tabVille as $uneVille){
$param["ville".$uneVille->getVille()->getId().""] = $uneVille->getVille()->getId();
}
}else{
( $tabVille == '0' || $tabVille == '') ? $sql .= '' : $param['ville'] = $tabVille;
}
}
$pageActuelleInt = (int) $pageActuelle;
$nbParPageInt = (int) $nbParPage;
if ($pageActuelleInt < 1) {
$pageActuelleInt = 1;
}
if ($nbParPageInt < 1) {
$nbParPageInt = 20;
}
$nbTotalPage = (int) ceil($nbTotal / $nbParPage);
if ($nbTotalPage < 1) {
$nbTotalPage = 1;
}
if ($pageActuelleInt > $nbTotalPage) {
$pageActuelleInt = $nbTotalPage;
}
// $query->setFirstResult(($page * $articles_per_page) - $articles_per_page);
// $query->setMaxResults($articles_per_page);
//var_dump($sql);exit;
//var_dump($deb);var_dump($fin);var_dump($sql); var_dump($param);exit;
// return $query->getResult();
// $query = $qb->getQuery();
$query = $this->_em->createQuery($sql);
$query->setParameters($param);
//var_dump( $query->getSQL());exit;
// $query->setFirstResult(($pageActuelleInt - 1) * $nbParPageInt);
// $query->setMaxResults($nbParPageInt);
// $rep['nbParPage'] = $nbParPage;
// $rep['pageActuelle'] = $pageActuelle;
// $rep['nbTotal'] = $nbTotal;
// $rep['nbTotalPage'] = $nbTotalPage;
// $rep['data'] = new Paginator($query);
// var_dump($query->getSQL());exit;
return $query->getResult();
}
}