Skip to content

Commit

Permalink
Recall Liste des chèques : export des inscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
sharevb committed Jul 25, 2018
1 parent b30a558 commit ae267cc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion class.amapress.php

Large diffs are not rendered by default.

23 changes: 17 additions & 6 deletions entities/contrat/recalls.php
Expand Up @@ -140,13 +140,24 @@ function ( $r ) {
'for_pdf' => true,
) );

$lieu = AmapressLieu_distribution::getBy( $lieu_id );
$date = date_i18n( 'd-m-Y' );
$filename = strtolower( sanitize_file_name( "cheques-{$contrat_instance->getModel()->getTitle()}-{$lieu->getShortName()}-au-$date" ) );
$title = "Chèques - {$contrat_instance->getModel()->getTitle()} - {$lieu->getShortName()}";
$lieu = AmapressLieu_distribution::getBy( $lieu_id );
$date = date_i18n( 'd-m-Y' );
$filename_cheques = strtolower( sanitize_file_name( "cheques-{$contrat_instance->getModel()->getTitle()}-{$lieu->getShortName()}-au-$date" ) );
$filename_adherents = strtolower( sanitize_file_name( "adherents-{$contrat_instance->getModel()->getTitle()}-{$lieu->getShortName()}-au-$date" ) );
$title_cheques = "Chèques - {$contrat_instance->getModel()->getTitle()} - {$lieu->getShortName()}";
if ( strlen( $title_cheques ) > 27 ) {
$title_cheques = substr( $title_cheques, 0, 27 ) . '...';
}
$title_adherents = "Adhérents - {$contrat_instance->getModel()->getTitle()} - {$lieu->getShortName()}";
if ( strlen( $title_adherents ) > 27 ) {
$title_adherents = substr( $title_adherents, 0, 27 ) . '...';
}

$attachments[] = Amapress::createPdfFromHtmlAsMailAttachment( $html, $filename . '.pdf', 'L', $format );
$attachments[] = Amapress::createXLSXFromHtmlAsMailAttachment( $html, $filename . '.xlsx', $title );
$attachments[] = Amapress::createPdfFromHtmlAsMailAttachment( $html, $filename_cheques . '.pdf', 'L', $format );
$attachments[] = Amapress::createXLSXFromHtmlAsMailAttachment( $html, $filename_cheques . '.xlsx', $title_cheques );
$attachments[] = Amapress::createXLSXFromPostQueryAsMailAttachment(
'post_type=amps_adhesion&amapress_contrat_inst=' . $contrat_instance->ID . '&amapress_lieu=' . $lieu_id,
$filename_adherents . '.xlsx', $title_adherents );
}
}

Expand Down
4 changes: 2 additions & 2 deletions utils/export-posts-to-csv.php
Expand Up @@ -73,7 +73,7 @@ public static function generate_csv() {
*
* @return PHPExcel
*/
public static function generate_phpexcel_sheet( $query_string, $base_export_name = null ) {
public static function generate_phpexcel_sheet( $query_string, $base_export_name = null, $title = null ) {
$args = array(
'fields' => 'all_with_meta',
'posts_per_page' => - 1,
Expand Down Expand Up @@ -169,7 +169,7 @@ public static function generate_phpexcel_sheet( $query_string, $base_export_name
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setCreator( "Amapress" )
->setLastModifiedBy( "Amapress" )
->setTitle( $export_name );
->setTitle( ! empty( $title ) ? $title : $export_name );
$objPHPExcel->setActiveSheetIndex( 0 )->fromArray( $csv_data );
$objPHPExcel->getActiveSheet()->setTitle( $export_name );
$objPHPExcel->setActiveSheetIndex( 0 );
Expand Down

0 comments on commit ae267cc

Please sign in to comment.