|
|
|
|
|
|
|
|
$this->redirect([$this->getControllerUrl() . '/index']); |
|
|
$this->redirect([$this->getControllerUrl() . '/index']); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function actionExportCsvEvoliz($id) |
|
|
|
|
|
{ |
|
|
|
|
|
$datas = []; |
|
|
|
|
|
$document = $this->findModel($id); |
|
|
|
|
|
|
|
|
|
|
|
// données |
|
|
|
|
|
$datas[] = [ |
|
|
|
|
|
'N° facture externe *', |
|
|
|
|
|
'Date facture *', |
|
|
|
|
|
'Client', |
|
|
|
|
|
'Code client *', |
|
|
|
|
|
'Total TVA', |
|
|
|
|
|
'Total HT', |
|
|
|
|
|
'Total TTC', |
|
|
|
|
|
'Total réglé', |
|
|
|
|
|
'Etat', |
|
|
|
|
|
'Date Etat', |
|
|
|
|
|
'Date de création', |
|
|
|
|
|
'Objet', |
|
|
|
|
|
'Date d\'échéance', |
|
|
|
|
|
'Date d\'exécution', |
|
|
|
|
|
'Taux de pénalité', |
|
|
|
|
|
'Frais de recouvrement', |
|
|
|
|
|
'Taux d\'escompte', |
|
|
|
|
|
'Conditions de règlement *', |
|
|
|
|
|
'Mode de paiement', |
|
|
|
|
|
'Remise globale', |
|
|
|
|
|
'Acompte', |
|
|
|
|
|
'Nombre de relance', |
|
|
|
|
|
'Commentaires', |
|
|
|
|
|
'N° facture', |
|
|
|
|
|
'Annulé', |
|
|
|
|
|
'Catalogue', |
|
|
|
|
|
'Réf.', |
|
|
|
|
|
'Désignation *', |
|
|
|
|
|
'Qté *', |
|
|
|
|
|
'Unité', |
|
|
|
|
|
'PU HT *', |
|
|
|
|
|
'Remise', |
|
|
|
|
|
'TVA', |
|
|
|
|
|
'Total TVA', |
|
|
|
|
|
'Total HT', |
|
|
|
|
|
'Créateur', |
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
foreach($document->getProductsOrders() as $productOrderArray) { |
|
|
|
|
|
foreach($productOrderArray as $productOrder) { |
|
|
|
|
|
|
|
|
|
|
|
$price = $productOrder->getPrice() ; |
|
|
|
|
|
if($document->isInvoicePrice() && $productOrder->getInvoicePrice()) { |
|
|
|
|
|
$price = $productOrder->getInvoicePrice() ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$datas[] = [ |
|
|
|
|
|
$document->reference, // N° facture externe * |
|
|
|
|
|
date('d/m/Y', strtotime($document->date)), // Date facture * |
|
|
|
|
|
'', // Client |
|
|
|
|
|
'C1', // Code client * |
|
|
|
|
|
'', // Total TVA |
|
|
|
|
|
'', // Total HT |
|
|
|
|
|
'', // Total TTC |
|
|
|
|
|
'', // Total réglé |
|
|
|
|
|
'', // Etat |
|
|
|
|
|
'', // Date Etat |
|
|
|
|
|
'', // Date de création |
|
|
|
|
|
$document->name, // Objet |
|
|
|
|
|
'', // Date d'échéance |
|
|
|
|
|
'', // Date d'exécution |
|
|
|
|
|
'', // Taux de pénalité |
|
|
|
|
|
'', // Frais de recouvrement |
|
|
|
|
|
'', // Taux d\'escompte |
|
|
|
|
|
'A réception', // Conditions de règlement * |
|
|
|
|
|
'', // Mode de paiement |
|
|
|
|
|
'', // Remise globale |
|
|
|
|
|
'', // Acompte |
|
|
|
|
|
'', // Nombre de relance |
|
|
|
|
|
'', // Commentaires |
|
|
|
|
|
'', // N° facture |
|
|
|
|
|
'', // Annulé |
|
|
|
|
|
'Non', // Catalogue |
|
|
|
|
|
'', // Réf. |
|
|
|
|
|
$productOrder->product->name, // Désignation * |
|
|
|
|
|
$productOrder->quantity, // Qté * |
|
|
|
|
|
'', // Product::strUnit($productOrder->unit, 'wording'), // Unité |
|
|
|
|
|
$price, // PU HT * |
|
|
|
|
|
'', // Remise |
|
|
|
|
|
$productOrder->taxRate->value * 100, // TVA |
|
|
|
|
|
'', // Total TVA |
|
|
|
|
|
'', // Total HT |
|
|
|
|
|
'', // Créateur |
|
|
|
|
|
]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// nom fichier |
|
|
|
|
|
$reference = $document->id; |
|
|
|
|
|
if($document->reference && strlen($document->reference)) { |
|
|
|
|
|
$reference = $document->reference; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// status |
|
|
|
|
|
$status = ''; |
|
|
|
|
|
if($document->isStatusDraft()) { |
|
|
|
|
|
$status = 'brouillon_'; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CSV::downloadSendHeaders(strtolower($this->getDocumentType()).'_' . $status . $reference . '.csv'); |
|
|
|
|
|
echo CSV::array2csv($datas); |
|
|
|
|
|
die(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public function actionDownload($id) |
|
|
public function actionDownload($id) |
|
|
{ |
|
|
{ |
|
|
$document = $this->findModel($id); |
|
|
$document = $this->findModel($id); |