src/Controller/Export/ExportController.php line 29

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Export;
  3. use App\Entity\Client;
  4. use App\Entity\Clientvente;
  5. use App\Entity\Fournisseur;
  6. use App\Entity\Moisvalide;
  7. use App\Excel\Excel;
  8. use Doctrine\ORM\EntityManagerInterface;
  9. use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
  10. use PhpOffice\PhpSpreadsheet\Writer\Xls;
  11. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\HttpFoundation\Response;
  14. use Symfony\Component\HttpFoundation\ResponseHeaderBag;
  15. use Symfony\Component\HttpFoundation\StreamedResponse;
  16. use Symfony\Component\Routing\Annotation\Route;
  17. use PhpOffice\PhpSpreadsheet\Style\Fill;
  18. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  19. class ExportController extends AbstractController
  20. {
  21. /**
  22. * @Route("/admin/", name="malys_export_homepage")
  23. */
  24. public function indexAction(EntityManagerInterface $em)
  25. {
  26. // FOURNISSEURS
  27. $fournisseurs = $em->getRepository(Fournisseur::class)->findAllOrderByNom()->getQuery()->getResult();
  28. return $this->render('export/index.html.twig', array('fournisseurs' => $fournisseurs));
  29. }
  30. /**
  31. * @Route("/admin/export_cactif", name="malys_export_cactif")
  32. */
  33. public function exportClientActifAction(EntityManagerInterface $em)
  34. {
  35. // Récupération des clients actifs
  36. $t_clients_actifs = $em->getRepository(Client::class)->findAllClientActifAndVisible();
  37. // Création du classeur
  38. $spreadsheet = new Spreadsheet();
  39. $sheet = $spreadsheet->getActiveSheet();
  40. $sheet->setTitle('Actifs');
  41. // Entêtes
  42. $sheet->setCellValue('A1', 'ID');
  43. $sheet->setCellValue('B1', 'Nom');
  44. $sheet->getStyle('A1:B1')->getFont()->setBold(true);
  45. // Remplissage des données
  46. $row = 2;
  47. $e = 0;
  48. foreach ($t_clients_actifs as $client) {
  49. // Selon ta structure : $client[0]['id'] et $client[0]['nom']
  50. $sheet->setCellValue('A' . $row, $client[0]['id']);
  51. $sheet->setCellValue('B' . $row, $client[0]['nom']);
  52. $row++;
  53. $e++;
  54. }
  55. // Génération du fichier Excel via StreamedResponse
  56. $response = new StreamedResponse(function() use ($spreadsheet) {
  57. $writer = new Xls($spreadsheet);
  58. $writer->save('php://output');
  59. });
  60. $filename = 'export_anp_' . date("Ymd_Hi") . '.xls';
  61. $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  62. $response->headers->set('Content-Disposition', 'inline; filename="' . $filename . '"');
  63. return $response;
  64. }
  65. /**
  66. * @Route("/admin/export_anp", name="malys_export_anp")
  67. */
  68. public function exportListActifNouveauPerduAction(EntityManagerInterface $em)
  69. {
  70. $annee = date("Y");
  71. // Récupère le mois validé le plus proche
  72. $MonthValid = $em->getRepository(Moisvalide::class)->findLastMoisvalide(date("n"), date("Y"));
  73. // Tous les clients avec CA par mois/année
  74. $t_allCaClientByMonth = $em->getRepository(Clientvente::class)
  75. ->getAllClientsCaLight($annee, null, 'three year', $this->getUser()->getId(), $this->getUser()->getFamille());
  76. $t_listClientActif = [];
  77. $t_listClientNouveau = [];
  78. $t_listClientPerdu = [];
  79. foreach ($t_allCaClientByMonth as $item) {
  80. $yearfr = $item['datefr']->format('Y');
  81. $monthfr = $item['datefr']->format('n');
  82. // Clients actifs du dernier mois validé
  83. if ($monthfr == $MonthValid[0]['mois'] && $yearfr == $MonthValid[0]['annee']) {
  84. if (!isset($t_listClientActif[$item['id']])) {
  85. $t_listClientActif[$item['id']] = $item['nom'];
  86. $t_listClientNouveau[$item['id']] = $item['nom'];
  87. }
  88. }
  89. // Clients perdus du mois précédent
  90. if ($monthfr == $MonthValid[0]['mois'] - 1 && $yearfr == $MonthValid[0]['annee']) {
  91. if (!isset($t_listClientPerdu[$item['id']])) {
  92. $t_listClientPerdu[$item['id']] = $item['nom'];
  93. }
  94. }
  95. }
  96. // Retirer les clients actifs de la liste des perdus
  97. foreach ($t_listClientPerdu as $k => $value) {
  98. if (isset($t_listClientActif[$k])) {
  99. unset($t_listClientPerdu[$k]);
  100. }
  101. }
  102. // Déterminer les nouveaux clients
  103. foreach ($t_allCaClientByMonth as $item) {
  104. $yearfr = $item['datefr']->format('Y');
  105. $monthfr = $item['datefr']->format('n');
  106. if ($yearfr == ($MonthValid[0]['annee'])) {
  107. if (in_array($monthfr, [
  108. $MonthValid[0]['mois'] - 1,
  109. $MonthValid[0]['mois'] - 2,
  110. $MonthValid[0]['mois'] - 3,
  111. $MonthValid[0]['mois'] - 4
  112. ])) {
  113. if (isset($t_listClientNouveau[$item['id']])) {
  114. unset($t_listClientNouveau[$item['id']]);
  115. }
  116. }
  117. }
  118. }
  119. // Création du classeur
  120. $spreadsheet = new Spreadsheet();
  121. // Feuille Actifs
  122. $sheetActifs = $spreadsheet->getActiveSheet();
  123. $sheetActifs->setTitle('Actifs');
  124. $sheetActifs->setCellValue('A1', 'ID');
  125. $sheetActifs->setCellValue('B1', 'Nom');
  126. $sheetActifs->getStyle('A1:B1')->getFont()->setBold(true);
  127. $row = 2;
  128. foreach ($t_listClientActif as $id => $nom) {
  129. $sheetActifs->setCellValue('A' . $row, $id);
  130. $sheetActifs->setCellValue('B' . $row, $nom);
  131. $row++;
  132. }
  133. // Feuille Nouveaux
  134. $sheetNouveaux = $spreadsheet->createSheet();
  135. $sheetNouveaux->setTitle('Nouveaux');
  136. $sheetNouveaux->setCellValue('A1', 'ID');
  137. $sheetNouveaux->setCellValue('B1', 'Nom');
  138. $sheetNouveaux->getStyle('A1:B1')->getFont()->setBold(true);
  139. $row = 2;
  140. foreach ($t_listClientNouveau as $id => $nom) {
  141. $sheetNouveaux->setCellValue('A' . $row, $id);
  142. $sheetNouveaux->setCellValue('B' . $row, $nom);
  143. $row++;
  144. }
  145. // Feuille Perdus
  146. $sheetPerdus = $spreadsheet->createSheet();
  147. $sheetPerdus->setTitle('Perdus');
  148. $sheetPerdus->setCellValue('A1', 'ID');
  149. $sheetPerdus->setCellValue('B1', 'Nom');
  150. $sheetPerdus->getStyle('A1:B1')->getFont()->setBold(true);
  151. $row = 2;
  152. foreach ($t_listClientPerdu as $id => $nom) {
  153. $sheetPerdus->setCellValue('A' . $row, $id);
  154. $sheetPerdus->setCellValue('B' . $row, $nom);
  155. $row++;
  156. }
  157. // Génération du fichier Excel via StreamedResponse
  158. $response = new StreamedResponse(function () use ($spreadsheet) {
  159. $writer = new Xls($spreadsheet);
  160. $writer->save('php://output');
  161. });
  162. $filename = 'export_anp_' . $MonthValid[0]['mois'] . '_' . $MonthValid[0]['annee'] . '_' . date("Ymd_Hi") . '.xls';
  163. $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  164. $response->headers->set('Content-Disposition', 'inline; filename="' . $filename . '"');
  165. return $response;
  166. }
  167. /**
  168. * @Route("/admin/export_cf", name="malys_export_cf")
  169. */
  170. public function exportCFAction(EntityManagerInterface $em)
  171. { $fournisseurs = $em->getRepository(Fournisseur::class)->findBy(['activite' => 1]);
  172. // GET CLIENTS
  173. $clients = $em->getRepository(Client::class)->findClientsWithAdmin(0);
  174. // GET PROSPECTS
  175. $prospects = $em->getRepository(Client::class)->findClientsWithAdmin(1);
  176. // Création du classeur
  177. $spreadsheet = new Spreadsheet();
  178. // --- Clients ---
  179. $sheetClients = $spreadsheet->getActiveSheet();
  180. $sheetClients->setTitle('Clients');
  181. $headerClients = ['id', 'nom', 'raison', 'adresse', 'cp', 'ville', 'contact', 'fonction', 'tel', 'mobile', 'fax', 'nomchef', 'mobilechef', 'email', 'activite', 'commercial'];
  182. $sheetClients->fromArray($headerClients, null, 'A1');
  183. $row = 2;
  184. foreach ($clients as $c) {
  185. $sheetClients->fromArray([
  186. $c['id'],
  187. $c['nom'],
  188. $c['raison'],
  189. $c['adresse'],
  190. $c['cp'],
  191. $c['ville'],
  192. $c['contact'],
  193. $c['fonction'],
  194. $c['tel'],
  195. $c['mobile'],
  196. $c['fax'],
  197. $c['nomchef'],
  198. $c['mobilechef'],
  199. $c['email'],
  200. $c['activite'] == 1 ? 'Actif' : 'Inactif',
  201. $c['idadmin']['contact'] ?? ''
  202. ], null, 'A'.$row);
  203. $row++;
  204. }
  205. // --- Prospects ---
  206. $sheetProspects = $spreadsheet->createSheet();
  207. $sheetProspects->setTitle('Prospects');
  208. $headerProspects = ['id', 'nom', 'raison', 'adresse', 'cp', 'ville', 'contact', 'fonction', 'tel', 'mobile', 'fax', 'nomchef', 'mobilechef', 'email', 'etat', 'commercial'];
  209. $sheetProspects->fromArray($headerProspects, null, 'A1');
  210. $row = 2;
  211. $etats = ['Mort', 'Froid', 'Chaud'];
  212. foreach ($prospects as $p) {
  213. $etat = $etats[$p['note']] ?? '';
  214. $sheetProspects->fromArray([
  215. $p['id'],
  216. $p['nom'],
  217. $p['raison'],
  218. $p['adresse'],
  219. $p['cp'],
  220. $p['ville'],
  221. $p['contact'],
  222. $p['fonction'],
  223. $p['tel'],
  224. $p['mobile'],
  225. $p['fax'],
  226. $p['nomchef'],
  227. $p['mobilechef'],
  228. $p['email'],
  229. $etat,
  230. $p['idadmin']['contact'] ?? ''
  231. ], null, 'A'.$row);
  232. $row++;
  233. }
  234. // --- Fournisseurs ---
  235. $sheetFournisseurs = $spreadsheet->createSheet();
  236. $sheetFournisseurs->setTitle('Fournisseurs');
  237. $headerFournisseurs = ['id', 'nom', 'raison', 'adresse', 'cp', 'ville', 'contact', 'fonction', 'tel', 'mobile', 'fax', 'email'];
  238. $sheetFournisseurs->fromArray($headerFournisseurs, null, 'A1');
  239. $row = 2;
  240. foreach ($fournisseurs as $f) {
  241. $sheetFournisseurs->fromArray([
  242. $f->getId(),
  243. $f->getNom(),
  244. $f->getRaison(),
  245. $f->getAdresse(),
  246. $f->getCp(),
  247. $f->getVille(),
  248. $f->getContact(),
  249. $f->getFonction(),
  250. $f->getTel(),
  251. $f->getMobile(),
  252. $f->getFax(),
  253. $f->getEmail()
  254. ], null, 'A'.$row);
  255. $row++;
  256. }
  257. // --- Génération du fichier Excel ---
  258. $writer = new Xls($spreadsheet);
  259. $filename = 'export_cf_' . date('Ymd_Hi') . '.xls';
  260. $temp_file = tempnam(sys_get_temp_dir(), $filename);
  261. $writer->save($temp_file);
  262. // --- Réponse Symfony ---
  263. return $this->file($temp_file, $filename, ResponseHeaderBag::DISPOSITION_INLINE);
  264. }
  265. /**
  266. * @Route("/admin/export_segments", name="malys_export_segments")
  267. */
  268. public function exportSegmentsAction(EntityManagerInterface $em)
  269. {
  270. // Récupération des fournisseurs
  271. $fournisseurs = $em->getRepository(Fournisseur::class)->findAllFournisseursWithClients();
  272. // Création du classeur
  273. $spreadsheet = new Spreadsheet();
  274. $firstSheet = true;
  275. foreach ($fournisseurs as $f) {
  276. // Feuille : si première, on utilise la feuille par défaut, sinon on crée une nouvelle
  277. if ($firstSheet) {
  278. $sheet = $spreadsheet->getActiveSheet();
  279. $firstSheet = false;
  280. } else {
  281. $sheet = $spreadsheet->createSheet();
  282. }
  283. // Nom de la feuille
  284. $nomFeuille = $f->getId() . "-" . strtoupper(substr($f->getNom() . (($f->getSource() == "restogest") ? " RSTG" : ""), 0, 27));
  285. $nomFeuille = preg_replace('/[:\\\\\/\?\*\[\]]/', '', $nomFeuille);
  286. $sheet->setTitle($nomFeuille);
  287. // Entêtes
  288. $sheet->setCellValue('A1', 'Nom');
  289. $sheet->setCellValue('B1', 'Raison');
  290. $sheet->setCellValue('C1', 'CP');
  291. $sheet->setCellValue('D1', 'Ville');
  292. $sheet->setCellValue('E1', 'Contact');
  293. $sheet->setCellValue('F1', 'Mobile');
  294. $sheet->setCellValue('G1', 'Email');
  295. $sheet->setCellValue('H1', 'Fournisseur');
  296. $sheet->getStyle('A1:H1')->getFont()->setBold(true);
  297. // Remplissage des clients
  298. $row = 2;
  299. foreach ($f->getClientrelation() as $cr) {
  300. $c = $cr->getIdclient();
  301. $sheet->setCellValue('A' . $row, $c->getNom());
  302. $sheet->setCellValue('B' . $row, $c->getRaison());
  303. $sheet->setCellValueExplicit('C' . $row, $c->getCp(), \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
  304. $sheet->setCellValue('D' . $row, $c->getVille());
  305. $sheet->setCellValue('E' . $row, $c->getContact());
  306. $sheet->setCellValueExplicit('F' . $row, $c->getMobile(), \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
  307. $sheet->setCellValueExplicit('G' . $row, $c->getEmail(), \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
  308. $sheet->setCellValue('H' . $row, $f->getNom());
  309. $row++;
  310. }
  311. }
  312. // Téléchargement direct via StreamedResponse
  313. $response = new StreamedResponse(function () use ($spreadsheet) {
  314. $writer = new Xls($spreadsheet);
  315. $writer->save('php://output');
  316. });
  317. $filename = 'export_segmentfc_' . date("Ymd_Hi") . '.xls';
  318. $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  319. $response->headers->set('Content-Disposition', 'inline; filename="' . $filename . '"');
  320. return $response;
  321. }
  322. /**
  323. * @Route("/admin/export_c_by_f", name="malys_export_c_by_f")
  324. */
  325. public function exportCByFAction(EntityManagerInterface $em)
  326. {
  327. // FOURNISSEURS
  328. $fournisseurs = $em->getRepository(Fournisseur::class)->findAllOrderByNom()->getQuery()->getResult();
  329. return $this->render('export/exportCByF_filter.html.twig', array('fournisseurs' => $fournisseurs));
  330. }
  331. /**
  332. * @Route("/admin/export_c_by_f_traitement", name="malys_export_c_by_f_traitement")
  333. */
  334. public function exportCByFTraitementAction(Request $request, EntityManagerInterface $em)
  335. {
  336. if ($request->isMethod('POST')) {
  337. $exclu = $request->request->get('exclu', []);
  338. $inclu = $request->request->get('inclu', []);
  339. if (!empty($exclu) || !empty($inclu)) {
  340. $clients_tab = $em->getRepository(Client::class)->findClientByFournisseursWorked($exclu, $inclu);
  341. } else {
  342. $clients_tab = $em->getRepository(Client::class)->findClientByFournisseursWorked();
  343. }
  344. if (empty($clients_tab)) {
  345. // FOURNISSEURS
  346. $fournisseurs = $em->getRepository(Fournisseur::class)->findAllOrderByNom()->getQuery()->getResult();
  347. return $this->render('export/exportCByF_filter.html.twig', ['fournisseurs' => $fournisseurs]);
  348. }
  349. // Création du classeur
  350. $spreadsheet = new Spreadsheet();
  351. $sheet = $spreadsheet->getActiveSheet();
  352. $sheet->setTitle('Clients');
  353. // Entêtes
  354. $headers = ['id', 'nom', 'raison', 'adresse', 'cp', 'ville', 'contact', 'fonction', 'tel', 'mobile', 'fax', 'nomchef', 'mobilechef', 'email', 'activite', 'commercial'];
  355. $col = 'A';
  356. foreach ($headers as $header) {
  357. $sheet->setCellValue($col . '1', $header);
  358. $sheet->getStyle($col . '1')->getFont()->setBold(true);
  359. $col++;
  360. }
  361. // Contenu
  362. $row = 2;
  363. foreach ($clients_tab as $c) {
  364. $sheet->setCellValue('A' . $row, $c['id']);
  365. $sheet->setCellValue('B' . $row, $c['nom']);
  366. $sheet->setCellValue('C' . $row, $c['raison']);
  367. $sheet->setCellValue('D' . $row, $c['adresse']);
  368. $sheet->setCellValueExplicit('E' . $row, $c['cp'], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
  369. $sheet->setCellValue('F' . $row, $c['ville']);
  370. $sheet->setCellValue('G' . $row, $c['contact']);
  371. $sheet->setCellValue('H' . $row, $c['fonction']);
  372. $sheet->setCellValueExplicit('I' . $row, $c['tel'], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
  373. $sheet->setCellValueExplicit('J' . $row, $c['mobile'], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
  374. $sheet->setCellValueExplicit('K' . $row, $c['fax'], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
  375. $sheet->setCellValue('L' . $row, $c['nomchef']);
  376. $sheet->setCellValueExplicit('M' . $row, $c['mobilechef'], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
  377. $sheet->setCellValueExplicit('N' . $row, $c['email'], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
  378. $sheet->setCellValue('O' . $row, ($c['activite'] == 1 ? 'Actif' : 'Inactif'));
  379. $sheet->setCellValue('P' . $row, $c['idadmin']['contact'] ?? '');
  380. $row++;
  381. }
  382. // Génération du fichier Excel
  383. $writer = new Xls($spreadsheet);
  384. $response = new StreamedResponse(function() use ($writer) {
  385. $writer->save('php://output');
  386. });
  387. $filename = 'ex_cli_by_frn_worked_' . date("Ymd_Hi") . '.xls';
  388. $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  389. $response->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"');
  390. return $response;
  391. }
  392. return false;
  393. }
  394. /**
  395. * @Route("/admin/export_client", name="malys_export_client")
  396. */
  397. public function exportClientsAction(EntityManagerInterface $em)
  398. {
  399. ini_set('display_errors', 1);
  400. error_reporting(E_ALL);
  401. set_time_limit(0);
  402. date_default_timezone_set('Europe/Paris');
  403. // $filePath = tempnam( "documents/tmp", ".xls" );
  404. //$this->get('malys_export.excel');
  405. // $workbook = new \writeexcel_workbook( $filePath );
  406. // $worksheet = $workbook->addworksheet( 'Clients' );
  407. // $heading = $workbook->addformat( array(
  408. // 'bold' => 1,
  409. // 'color' => 'black',
  410. // 'size' => 12,
  411. // 'merge' => 1
  412. // ) );
  413. $now = new \DateTime();
  414. $now->modify('-1 month');
  415. $monthAgo = new \DateTime('last month');
  416. $monthAgo->modify('-1 month');
  417. // $worksheet->write( "A1", "Client", $heading );
  418. // $worksheet->write( "B1", "Commercial", $heading );
  419. //
  420. // $worksheet->write( "C1", "CA " . $now->format( "F Y" ) );
  421. // $worksheet->write( "D1", "Solde " . $now->format( "F Y" ) );
  422. //
  423. // $worksheet->write( "E1", "CA " . $monthAgo->format( "F Y" ) );
  424. // $worksheet->write( "F1", "Solde " . $monthAgo->format( "F Y" ) );
  425. // $response = new \Symfony\Component\HttpFoundation\Response;
  426. // $response->headers->set( 'Content-Type', 'application/vnd.ms-excel' );
  427. // $response->headers->set( 'Content-Disposition', 'attachment; filename="exportClients_' . date( "Ymd" ) . '_' . date( "Hi" ) . '.xls"' );
  428. // $response->setContent( file_get_contents( $filePath ) );
  429. // unlink( $filePath );
  430. $ventesRepo = $em->getRepository(Clientvente::class);
  431. $customerRepo = $em->getRepository(Client::class);
  432. $clients = $customerRepo->findBy(
  433. [
  434. 'affiche' => 1,
  435. 'prospect' => 0
  436. ]
  437. );
  438. usort($clients, function ($a, $b) {
  439. return ($a->getIdadmin()->getId() < $b->getIdadmin()->getId()) ? -1 : 1;
  440. });
  441. $thisMonthStart = new \DateTime('first day of this month');
  442. $thisMonthStart->modify('-1 month');
  443. $thisMonthStartStr = $thisMonthStart->format('Y-m-d');
  444. $thisMonthEnd = new \DateTime('last day of this month');
  445. $thisMonthEnd->modify('-1 month');
  446. $thisMonthEndStr = $thisMonthEnd->format('Y-m-d');
  447. $lastMonthStart = new \DateTime('first day of last month');
  448. $lastMonthStart->modify('-1 month');
  449. $lastMonthStartStr = $lastMonthStart->format('Y-m-d');
  450. $lastMonthEnd = new \DateTime('last day of last month');
  451. $lastMonthEnd->modify('-1 month');
  452. $lastMonthEndStr = $lastMonthEnd->format('Y-m-d');
  453. $infos = [];
  454. foreach ($clients as $client) {
  455. $thisMonthVentes = $ventesRepo->getCustomerBetweenDates($client, $thisMonthStartStr, $thisMonthEndStr);
  456. $lastMonthVentes = $ventesRepo->getCustomerBetweenDates($client, $lastMonthStartStr, $lastMonthEndStr);
  457. $clientInfos = [];
  458. $clientInfos['entity'] = $client;
  459. $clientInfos['thisMonthCA'] = $this->getCA($thisMonthVentes);
  460. $clientInfos['thisMonthSolde'] = $this->getSolde($thisMonthVentes);
  461. $clientInfos['lastMonthCA'] = $this->getCA($lastMonthVentes);
  462. $clientInfos['lastMonthSolde'] = $this->getSolde($lastMonthVentes);
  463. $infos[] = $clientInfos;
  464. }
  465. return $this->render('export/ClientPerAgent.html.twig', array(
  466. 'now' => $now,
  467. 'monthAgo' => $monthAgo,
  468. 'infos' => $infos
  469. ));
  470. }
  471. private function getCA($ventes)
  472. {
  473. $result = 0;
  474. foreach ($ventes as $vente) {
  475. $venteCA = $vente->getMontantht();
  476. $result = $result + $venteCA;
  477. }
  478. $result = str_replace('.', ',', $result);
  479. return $result;
  480. }
  481. private function getSolde($ventes)
  482. {
  483. $result = 0;
  484. foreach ($ventes as $vente) {
  485. $venteCA = $vente->getSolde();
  486. $result = $result + $venteCA;
  487. }
  488. $result = str_replace('.', ',', $result);
  489. return $result;
  490. }
  491. }