ScanReportPdf.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <?php
  2. class ScanReportPdf extends FPDF {
  3. protected static $CELL_WIDTH = 90;
  4. protected static $CELL_LABEL_WIDTH = 80;
  5. protected static $LINE_HEIGHT = 10;
  6. protected static $LEFT_MARGIN = 10;
  7. protected static $TOP_MARGIN = 10;
  8. protected static $ROW = 0;
  9. protected static $TEXT_HEIGHT = 5;
  10. protected $pdf;
  11. protected $titre;
  12. function __construct($titre)
  13. {
  14. $this->titre = $titre;
  15. parent::__construct();
  16. $this->AddPage();
  17. $this->SetTextColor(0x00, 0x00, 0x00);
  18. $this->SetTextColor(0x00, 0x00, 0x00);
  19. $this->SetFont('Arial', '', 8);
  20. $datas = array_map("utf8_decode", $datas);
  21. }
  22. public function setPrestaSubscriptionData($datas)
  23. {
  24. foreach($datas as $key => $d) {
  25. switch ($key) {
  26. case 'card_lost':
  27. if($d != ''){
  28. $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(PrestataireAdhesionForm::$HASH_KEYS[$key]) , 0, 0, 'L', false);
  29. $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(PrestataireAdhesionForm::$HASH_CARD_LOST[$d]) , 0, 1, 'L', false);
  30. }
  31. break;
  32. case 'payment_mode':
  33. if($d != ''){
  34. $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(PrestataireAdhesionForm::$HASH_KEYS[$key]) , 0, 0, 'L', false);
  35. $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(PrestataireAdhesionForm::$HASH_PAYMENT_MODE[$d]) , 0, 1, 'L', false);
  36. }
  37. break;
  38. case 'payment_amount':
  39. if($d != ''){
  40. $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(PrestataireAdhesionForm::$HASH_KEYS[$key]) , 0, 0, 'L', false);
  41. $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(PrestataireAdhesionForm::$HASH_PAYMENT_AMOUNT[$d]) , 0, 1, 'L', false);
  42. }
  43. break;
  44. default:
  45. if(array_key_exists($key, PrestataireAdhesionForm::$HASH_KEYS)){
  46. $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(PrestataireAdhesionForm::$HASH_KEYS[$key]) , 0, 0, 'L', false);
  47. $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode($d) , 0, 1, 'L', false);
  48. }else {
  49. $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode($key) , 0, 0, 'L', false);
  50. $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode($d) , 0, 1, 'L', false);
  51. }
  52. }
  53. }
  54. }
  55. public function generateForm($formschema){
  56. //var_dump($formschema);
  57. $labels = $formschema->getLabels();
  58. $fields = $formschema->getFields();
  59. foreach($labels as $key => $l){ // O
  60. $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(PrestataireAdhesionForm::$HASH_KEYS[$key]." : " ), 0, 0, 'L', false);
  61. foreach($fields as $key2 => $f){
  62. if($key == $key2){
  63. $choices = $f->getOption('choices');
  64. if($choices != null){
  65. $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, '', 0, 1);
  66. foreach ($choices as $c) {
  67. $this->SetX('50');
  68. $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode('[ ] '.$c) , 0, 1, 'L', false);
  69. }
  70. } else {
  71. $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode('________________________') , 0, 1, 'l', false);
  72. }
  73. }
  74. }
  75. }
  76. }
  77. public function setAdherentSubscriptionDatas($datas){
  78. $this->SetTextColor(50, 50, 50);
  79. foreach($datas as $key => $d) {
  80. switch ($key) {
  81. case 'user_payment_mode':
  82. if($d != ''){
  83. $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(AdherentSubscriptionForm::$HASH_KEYS[$key]) , 0, 0, 'L', false);
  84. foreach (AdherentSubscriptionForm::$HASH_PAYMENT_MODE as $cle => $payment_method) {
  85. if($cle != 0) {
  86. $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, '', 0, 0, 'L', false);
  87. }
  88. if($cle == $d)
  89. $this->cell(4, self::$TEXT_HEIGHT, '[x]', 0, 0, 'L', false);
  90. else
  91. $this->cell(4, self::$TEXT_HEIGHT, '[ ]', 0, 0, 'L', false);
  92. $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(AdherentSubscriptionForm::$HASH_PAYMENT_MODE[$cle]) , 0, 1, 'L', false);
  93. }
  94. $this->Ln(1);
  95. }
  96. break;
  97. case 'user_payment_amount':
  98. $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(AdherentSubscriptionForm::$HASH_KEYS[$key]) , 0, 0, 'L', false);
  99. // $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(AdherentSubscriptionForm::$HASH_PAYMENT_AMOUNT[$d]) , 0, 1, 'L', false);
  100. foreach (AdherentSubscriptionForm::$HASH_PAYMENT_AMOUNT as $cle => $payment_amount) {
  101. ($cle==0)?:$this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, '' , 0, 0, 'L', false);
  102. if($cle == $d)
  103. $this->cell(4, self::$TEXT_HEIGHT, '[x]', 0, 0, 'L', false);
  104. else
  105. $this->cell(4, self::$TEXT_HEIGHT, '[ ]', 0, 0, 'L', false);
  106. $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode($payment_amount) , 0, 1, 'L', false);
  107. }
  108. $this->Ln(1);
  109. break;
  110. case 'user_payment_mode_cheque':
  111. if($d != ''){
  112. $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(AdherentSubscriptionForm::$HASH_KEYS[$key]) , 0, 0, 'L', false);
  113. $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode($d) , 0, 1, 'L', false);
  114. $this->Ln(1);
  115. }
  116. break;
  117. case 'user_parraining':
  118. if($d != ''){
  119. $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(AdherentSubscriptionForm::$HASH_KEYS[$key]) , 0, 0, 'L', false);
  120. $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, $d , 0, 1, 'L', false);
  121. $this->Ln(1);
  122. }
  123. break;
  124. case 'user_membercard_lost':
  125. $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, 'Carte perdue?' , 0, 0, 'L', false);
  126. $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);
  127. $this->Ln(1);
  128. break;
  129. default:
  130. $this->SetFont('Arial','B',10);
  131. $this->cell(self::$CELL_LABEL_WIDTH, self::$TEXT_HEIGHT, utf8_decode(AdherentSubscriptionForm::$HASH_KEYS[$key]) , 0, 0, 'L', false);
  132. $this->cell(self::$CELL_WIDTH, self::$TEXT_HEIGHT, utf8_decode($d) , 0, 1, 'L', false);
  133. $this->Ln(1);
  134. }
  135. }
  136. }
  137. public function execute($fileName){
  138. return $this->Output(sfConfig::get('sf_upload_dir').'/'.$fileName, 'F');
  139. }
  140. public function Header()
  141. {
  142. $this->drawLogo();
  143. $this->SetFont('Arial','B',20);
  144. $this->SetTextColor(100, 100, 100);
  145. $this->Cell(135,20, utf8_decode($this->titre),0,0,'C');
  146. $this->Ln(40);
  147. }
  148. function drawLogo(){
  149. $top = 10;
  150. $position = 10;
  151. $this->setXY($position, $top);
  152. $this->Image(sfConfig::get('sf_web_dir') . '/images/logo.gif', $position, 10, 15);
  153. }
  154. }
  155. ?>