123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <?php
- class ScanReportPdf extends FPDF {
- protected static $CELL_WIDTH = 90;
- protected static $CELL_LABEL_WIDTH = 80;
- protected static $LINE_HEIGHT = 10;
- protected static $LEFT_MARGIN = 10;
- protected static $TOP_MARGIN = 10;
- protected static $ROW = 0;
- protected static $TEXT_HEIGHT = 5;
- protected $pdf;
- protected $titre;
- function __construct($titre)
- {
- $this->titre = $titre;
- parent::__construct();
- $this->AddPage();
- $this->SetTextColor(0x00, 0x00, 0x00);
- $this->SetTextColor(0x00, 0x00, 0x00);
- $this->SetFont('Arial', '', 8);
- $datas = array_map("utf8_decode", $datas);
- }
- public function setPrestaSubscriptionData($datas)
- {
- foreach($datas as $key => $d) {
- switch ($key) {
- case 'card_lost':
- if($d != ''){
- $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(PrestataireAdhesionForm::$HASH_KEYS[$key]) , 0, 0, 'L', false);
- $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(PrestataireAdhesionForm::$HASH_CARD_LOST[$d]) , 0, 1, 'L', false);
- }
- break;
- case 'payment_mode':
- if($d != ''){
- $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(PrestataireAdhesionForm::$HASH_KEYS[$key]) , 0, 0, 'L', false);
- $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(PrestataireAdhesionForm::$HASH_PAYMENT_MODE[$d]) , 0, 1, 'L', false);
- }
- break;
- case 'payment_amount':
- if($d != ''){
- $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(PrestataireAdhesionForm::$HASH_KEYS[$key]) , 0, 0, 'L', false);
- $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(PrestataireAdhesionForm::$HASH_PAYMENT_AMOUNT[$d]) , 0, 1, 'L', false);
- }
- break;
- default:
- if(array_key_exists($key, PrestataireAdhesionForm::$HASH_KEYS)){
- $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(PrestataireAdhesionForm::$HASH_KEYS[$key]) , 0, 0, 'L', false);
- $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode($d) , 0, 1, 'L', false);
- }else {
- $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode($key) , 0, 0, 'L', false);
- $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode($d) , 0, 1, 'L', false);
- }
- }
- }
- }
- public function generateForm($formschema){
- //var_dump($formschema);
- $labels = $formschema->getLabels();
- $fields = $formschema->getFields();
- foreach($labels as $key => $l){ // O
- $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(PrestataireAdhesionForm::$HASH_KEYS[$key]." : " ), 0, 0, 'L', false);
- foreach($fields as $key2 => $f){
- if($key == $key2){
- $choices = $f->getOption('choices');
- if($choices != null){
- $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, '', 0, 1);
- foreach ($choices as $c) {
- $this->SetX('50');
- $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode('[ ] '.$c) , 0, 1, 'L', false);
- }
- } else {
- $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode('________________________') , 0, 1, 'l', false);
- }
- }
- }
- }
- }
- public function setAdherentSubscriptionDatas($datas){
- $this->SetTextColor(50, 50, 50);
- foreach($datas as $key => $d) {
- switch ($key) {
- case 'user_payment_mode':
- if($d != ''){
- $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(AdherentSubscriptionForm::$HASH_KEYS[$key]) , 0, 0, 'L', false);
- foreach (AdherentSubscriptionForm::$HASH_PAYMENT_MODE as $cle => $payment_method) {
- if($cle != 0) {
- $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, '', 0, 0, 'L', false);
- }
- if($cle == $d)
- $this->cell(4, self::$TEXT_HEIGHT, '[x]', 0, 0, 'L', false);
- else
- $this->cell(4, self::$TEXT_HEIGHT, '[ ]', 0, 0, 'L', false);
- $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(AdherentSubscriptionForm::$HASH_PAYMENT_MODE[$cle]) , 0, 1, 'L', false);
- }
- $this->Ln(1);
- }
- break;
- case 'user_payment_amount':
- $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(AdherentSubscriptionForm::$HASH_KEYS[$key]) , 0, 0, 'L', false);
- // $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(AdherentSubscriptionForm::$HASH_PAYMENT_AMOUNT[$d]) , 0, 1, 'L', false);
- foreach (AdherentSubscriptionForm::$HASH_PAYMENT_AMOUNT as $cle => $payment_amount) {
- ($cle==0)?:$this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, '' , 0, 0, 'L', false);
- if($cle == $d)
- $this->cell(4, self::$TEXT_HEIGHT, '[x]', 0, 0, 'L', false);
- else
- $this->cell(4, self::$TEXT_HEIGHT, '[ ]', 0, 0, 'L', false);
- $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode($payment_amount) , 0, 1, 'L', false);
- }
- $this->Ln(1);
- break;
- case 'user_payment_mode_cheque':
- if($d != ''){
- $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(AdherentSubscriptionForm::$HASH_KEYS[$key]) , 0, 0, 'L', false);
- $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode($d) , 0, 1, 'L', false);
- $this->Ln(1);
- }
- break;
- case 'user_parraining':
- if($d != ''){
- $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(AdherentSubscriptionForm::$HASH_KEYS[$key]) , 0, 0, 'L', false);
- $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, $d , 0, 1, 'L', false);
- $this->Ln(1);
- }
- break;
- case 'user_membercard_lost':
- $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, 'Carte perdue?' , 0, 0, 'L', false);
- $d=='on'? $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, 'Oui' , 0, 1, 'L', false): $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, 'Non' , 0, 1, 'L', false);
- $this->Ln(1);
- break;
- default:
- $this->SetFont('Arial','B',10);
- $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(AdherentSubscriptionForm::$HASH_KEYS[$key]) , 0, 0, 'L', false);
- $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode($d) , 0, 1, 'L', false);
- $this->Ln(1);
- }
- }
- }
- public function execute($fileName){
- return $this->Output(sfConfig::get('sf_upload_dir').'/'.$fileName, 'F');
- }
- public function Header()
- {
- $this->drawLogo();
- $this->SetFont('Arial','B',20);
- $this->SetTextColor(100, 100, 100);
- $this->Cell(135,20, utf8_decode($this->titre),0,0,'C');
- $this->Ln(40);
- }
- function drawLogo(){
- $top = 10;
- $position = 10;
- $this->setXY($position, $top);
- $this->Image(sfConfig::get('sf_web_dir') . '/images/logo.gif', $position, 10, 15);
- }
- }
- ?>
|