| | 465 | |
|---|
| | 466 | public function executePrint($request) |
|---|
| | 467 | { |
|---|
| | 468 | $markets[] = MarketPeer::retrieveByPk($this->getRequestParameter('id')); |
|---|
| | 469 | |
|---|
| | 470 | // helpers |
|---|
| | 471 | sfLoader::loadHelpers('Date', 'Number'); |
|---|
| | 472 | |
|---|
| | 473 | // lang choice |
|---|
| | 474 | $lang = $this->getUser()->getCulture(); |
|---|
| | 475 | if($request->getParameter('lang')) |
|---|
| | 476 | $this->getUser()->setCulture($request->getParameter('lang')); |
|---|
| | 477 | |
|---|
| | 478 | // new PDF document |
|---|
| | 479 | $pdf = new templatepdf2('P','mm','A4'); |
|---|
| | 480 | $pdf->AddFont('Vera','','vera.php'); |
|---|
| | 481 | $pdf->AddFont('Vera','B','verab.php'); |
|---|
| | 482 | |
|---|
| | 483 | // agency |
|---|
| | 484 | $agency = AgencyPeer::retrieveByPk($this->getUser()->getSubscriber()->getAgencyId()); |
|---|
| | 485 | |
|---|
| | 486 | // pdf header |
|---|
| | 487 | define('AGENCE_ID', $agency->getId()); |
|---|
| | 488 | define('AGENCE_NAME', $agency->getBrand().' '.$agency); |
|---|
| | 489 | define('AGENCE_ADR1', $agency->getAddress1()); |
|---|
| | 490 | define('AGENCE_ADR2', $agency->getAddress2()); |
|---|
| | 491 | define('AGENCE_CITY', $agency->getPostalCode().' '.$agency->getCity()); |
|---|
| | 492 | define('AGENCE_TEL', ucfirst($this->getContext()->getI18N()->__('phone')).'. '.$agency->getTel()); |
|---|
| | 493 | define('AGENCE_FAX', ucfirst($this->getContext()->getI18N()->__('fax')).'. '.$agency->getFax()); |
|---|
| | 494 | define('AGENCE_MAIL', $agency->getMail()); |
|---|
| | 495 | define('AGENCE_URL', $agency->getUrl()); |
|---|
| | 496 | define('AGENCE_IMG', $agency->getLogoUrl(true)); |
|---|
| | 497 | define('USER_SHOW', true); |
|---|
| | 498 | |
|---|
| | 499 | // colors |
|---|
| | 500 | $c = new Criteria(); |
|---|
| | 501 | $c->add(ParamsPeer::AGENCY_ID, $this->getUser()->getSubscriber()->getAgencyId()); |
|---|
| | 502 | $c->add(ParamsPeer::NAME,'VitrineColor'); |
|---|
| | 503 | $vitrinecolors = ParamsPeer::doSelect($c); |
|---|
| | 504 | |
|---|
| | 505 | if(!$vitrinecolors): |
|---|
| | 506 | $c = new Criteria(); |
|---|
| | 507 | $c->add(ParamsPeer::COMPANY_ID, $this->getUser()->getSubscriber()->getCompanyId()); |
|---|
| | 508 | $c->add(ParamsPeer::NAME,'VitrineColor'); |
|---|
| | 509 | $vitrinecolors = ParamsPeer::doSelect($c); |
|---|
| | 510 | endif; |
|---|
| | 511 | |
|---|
| | 512 | if(!$vitrinecolors): |
|---|
| | 513 | $c = new Criteria(); |
|---|
| | 514 | $c->add(ParamsPeer::BRAND_ID, $this->getUser()->getSubscriber()->getAgency()->getBrandId()); |
|---|
| | 515 | $c->add(ParamsPeer::NAME,'VitrineColor'); |
|---|
| | 516 | $vitrinecolors = ParamsPeer::doSelect($c); |
|---|
| | 517 | endif; |
|---|
| | 518 | |
|---|
| | 519 | $i = 0; |
|---|
| | 520 | foreach($vitrinecolors as $vitrinecolor): |
|---|
| | 521 | $i++; |
|---|
| | 522 | $temp = explode('|', $vitrinecolor->getParam()); |
|---|
| | 523 | $colorname[$i] = $temp[0]; |
|---|
| | 524 | $colorcode[$i] = $temp[1]; |
|---|
| | 525 | endforeach; |
|---|
| | 526 | |
|---|
| | 527 | $pdfcolors = explode(',',$colorcode[1]); |
|---|
| | 528 | define('PDFCOLOR1a',$pdfcolors[0]); |
|---|
| | 529 | define('PDFCOLOR1b',$pdfcolors[1]); |
|---|
| | 530 | define('PDFCOLOR1c',$pdfcolors[2]); |
|---|
| | 531 | |
|---|
| | 532 | $pdfcolors = explode(',',$colorcode[2]); |
|---|
| | 533 | define('PDFCOLOR2a',$pdfcolors[0]); |
|---|
| | 534 | define('PDFCOLOR2b',$pdfcolors[1]); |
|---|
| | 535 | define('PDFCOLOR2c',$pdfcolors[2]); |
|---|
| | 536 | |
|---|
| | 537 | $police['titre'] = 12; |
|---|
| | 538 | $police['texte'] = 9; |
|---|
| | 539 | $police['petit'] = 6; |
|---|
| | 540 | |
|---|
| | 541 | foreach($markets as $market): |
|---|
| | 542 | // pictures list |
|---|
| | 543 | $c = new Criteria(); |
|---|
| | 544 | $c->add(PicturePeer::MARKET_ID, $market->getId()); |
|---|
| | 545 | $c->addDescendingOrderByColumn(PicturePeer::DEFAULT_PICTURE); |
|---|
| | 546 | $c->addAscendingOrderByColumn(PicturePeer::RANK); |
|---|
| | 547 | $c->addAscendingOrderByColumn(PicturePeer::ID); |
|---|
| | 548 | $pictures = PicturePeer::doSelect($c); |
|---|
| | 549 | $pictures_count = PicturePeer::doCount($c); |
|---|
| | 550 | |
|---|
| | 551 | //header infos |
|---|
| | 552 | global $TITLE; |
|---|
| | 553 | $TITLE = $market; |
|---|
| | 554 | |
|---|
| | 555 | //fiche produit |
|---|
| | 556 | if($this->getRequestParameter('product')!='false' && ($this->getRequestParameter('product')==true || $this->getRequestParameter('product')==1)): |
|---|
| | 557 | $ln_texte = 4; |
|---|
| | 558 | $pdf->AddPage(); |
|---|
| | 559 | |
|---|
| | 560 | //footer infos |
|---|
| | 561 | global $PRICE; |
|---|
| | 562 | $PRICE = $market->getPriceWithI18n(); |
|---|
| | 563 | define('PRICE_SHOW', true); |
|---|
| | 564 | |
|---|
| | 565 | //picture |
|---|
| | 566 | if(count($pictures)>0): |
|---|
| | 567 | $path = sfConfig::get('sf_upload_dir').'/market_pictures/'.$market->getId().'/'; |
|---|
| | 568 | $img_sizes = getimagesize($path.$pictures[0]->getName().'_400.'.$pictures[0]->getFormat()); |
|---|
| | 569 | $img_l = $img_sizes[0]; |
|---|
| | 570 | $img_h = $img_sizes[1]; |
|---|
| | 571 | $pict_h = 0; |
|---|
| | 572 | if($img_sizes[0]>$img_sizes[1]): |
|---|
| | 573 | $pict_l = 110; |
|---|
| | 574 | $pict_h = $img_h/$img_l*$pict_l; |
|---|
| | 575 | else: |
|---|
| | 576 | $pict_h = 80; |
|---|
| | 577 | $pict_l = $img_l/$img_h*$pict_h; |
|---|
| | 578 | endif; |
|---|
| | 579 | $pdf->Image($path.$pictures[0]->getName().'_400.'.$pictures[0]->getFormat(), 10, 60, $pict_l, $pict_h); |
|---|
| | 580 | endif; |
|---|
| | 581 | @$positionYimage = $pdf->getY()+$pict_h; |
|---|
| | 582 | |
|---|
| | 583 | // comment |
|---|
| | 584 | $pdf->SetY($positionYimage); |
|---|
| | 585 | $pdf->SetTextColor(0,0,0); |
|---|
| | 586 | $pdf->Ln(5); |
|---|
| | 587 | $pdf->SetFont('Vera','B',$police['texte']); |
|---|
| | 588 | if($this->getUser()->getCulture()=='fr_FR') |
|---|
| | 589 | $pdf->MultiCell(110,4,$market->getComment()."\n"); |
|---|
| | 590 | $positionYcomment = $pdf->getY(); |
|---|
| | 591 | |
|---|
| | 592 | $pdf->SetY(60); |
|---|
| | 593 | $pdf->SetFont('Vera','',12); |
|---|
| | 594 | $pdf->SetTextColor(0,103,179); |
|---|
| | 595 | $pdf->SetFillColor(220); |
|---|
| | 596 | $pdf->SetDrawColor(150); |
|---|
| | 597 | $pdf->SetX(125); |
|---|
| | 598 | |
|---|
| | 599 | // icons |
|---|
| | 600 | foreach($market->getIcons(30) as $icon): |
|---|
| | 601 | $pdf->Image($_SERVER['DOCUMENT_ROOT'].'/images/'.$icon[0], $pdf->getX(), $pdf->getY()); |
|---|
| | 602 | $pdf->SetX($pdf->getX()+14); |
|---|
| | 603 | endforeach; |
|---|
| | 604 | |
|---|
| | 605 | $pdf->SetY($pdf->getY()+14); |
|---|
| | 606 | $pdf->SetX(125); |
|---|
| | 607 | $pdf->Cell(0,5,ucfirst(__('mandate')),1,0,'L',1); |
|---|
| | 608 | $pdf->Cell(0,5,'S'.$market->getMandatNumber(),0,0,'R'); |
|---|
| | 609 | $pdf->Ln(7); |
|---|
| | 610 | |
|---|
| | 611 | $pdf->SetFont('Vera','',$police['texte']); |
|---|
| | 612 | $pdf->SetTextColor(0,0,0); |
|---|
| | 613 | if($market->getId()): |
|---|
| | 614 | $pdf->SetX(125); |
|---|
| | 615 | $pdf->Cell(0,5,ucfirst(__('reference')),0,0,'L'); |
|---|
| | 616 | $pdf->Cell(0,5,$market->getId(),0,0,'R'); |
|---|
| | 617 | $pdf->Ln($ln_texte); |
|---|
| | 618 | endif; |
|---|
| | 619 | |
|---|
| | 620 | if($market->getDistrictId()): |
|---|
| | 621 | $pdf->SetX(125); |
|---|
| | 622 | $pdf->Cell(0,5,ucfirst(__('sector')),0,0,'L'); |
|---|
| | 623 | $pdf->Cell(0,5,substr($market->getApidistrict(),0,23),0,0,'R'); |
|---|
| | 624 | $pdf->Ln($ln_texte); |
|---|
| | 625 | endif; |
|---|
| | 626 | |
|---|
| | 627 | if($market->getTotalSurface()>0): |
|---|
| | 628 | $pdf->SetX(125); |
|---|
| | 629 | $pdf->Cell(0,5,ucfirst(__('area')),0,0,'L'); |
|---|
| | 630 | $pdf->Cell(0,5,$market->getTotalSurface().' m²',0,0,'R'); |
|---|
| | 631 | $pdf->Ln($ln_texte); |
|---|
| | 632 | endif; |
|---|
| | 633 | |
|---|
| | 634 | if($market->getGardenSurface()>0): |
|---|
| | 635 | $pdf->SetX(125); |
|---|
| | 636 | $pdf->Cell(0,5,ucfirst(__('garden')),0,0,'L'); |
|---|
| | 637 | $pdf->Cell(0,5,$market->getGardenSurface().' m²',0,0,'R'); |
|---|
| | 638 | $pdf->Ln($ln_texte); |
|---|
| | 639 | endif; |
|---|
| | 640 | |
|---|
| | 641 | if($market->getTerraceSurface()>0): |
|---|
| | 642 | $pdf->SetX(125); |
|---|
| | 643 | $pdf->Cell(0,5,ucfirst(__('terrace')),0,0,'L'); |
|---|
| | 644 | $pdf->Cell(0,5,$market->getTerraceSurface().' m²',0,0,'R'); |
|---|
| | 645 | $pdf->Ln($ln_texte); |
|---|
| | 646 | endif; |
|---|
| | 647 | |
|---|
| | 648 | if($market->getParts()>0): |
|---|
| | 649 | $pdf->SetX(125); |
|---|
| | 650 | $pdf->Cell(0,5,ucfirst(__('rooms')),0,0,'L'); |
|---|
| | 651 | $pdf->Cell(0,5,$market->getParts(),0,0,'R'); |
|---|
| | 652 | $pdf->Ln($ln_texte); |
|---|
| | 653 | endif; |
|---|
| | 654 | |
|---|
| | 655 | if($market->getLevel() || $market->getLevels()): |
|---|
| | 656 | if($market->getLevels()) |
|---|
| | 657 | $etage = ' / '.$market->getLevels(); |
|---|
| | 658 | else |
|---|
| | 659 | $etage = ''; |
|---|
| | 660 | $pdf->SetX(125); |
|---|
| | 661 | $pdf->Cell(0,5,ucfirst(__('floor')),0,0,'L'); |
|---|
| | 662 | $pdf->Cell(0,5,$market->getLevel().$etage,0,0,'R'); |
|---|
| | 663 | $pdf->Ln($ln_texte); |
|---|
| | 664 | endif; |
|---|
| | 665 | |
|---|
| | 666 | $pdf->Ln($ln_texte); |
|---|
| | 667 | $pdf->SetTextColor(0,103,179); |
|---|
| | 668 | $pdf->SetFont('Vera','',12); |
|---|
| | 669 | $pdf->SetFillColor(220); |
|---|
| | 670 | $pdf->SetDrawColor(150); |
|---|
| | 671 | $pdf->SetX(125); |
|---|
| | 672 | $pdf->Cell(0,5,ucfirst(__('details')),1,0,'L',1); |
|---|
| | 673 | $pdf->Ln(7); |
|---|
| | 674 | $pdf->SetFont('Vera','',$police['texte']); |
|---|
| | 675 | $pdf->SetTextColor(0,0,0); |
|---|
| | 676 | |
|---|
| | 677 | if($market->getCaves()>0): |
|---|
| | 678 | $pdf->SetX(125); |
|---|
| | 679 | $pdf->Cell(0,5,ucfirst(__('cellar')),0,0,'L'); |
|---|
| | 680 | $pdf->Cell(0,5,$market->getCaves(),0,0,'R'); |
|---|
| | 681 | $pdf->Ln($ln_texte); |
|---|
| | 682 | endif; |
|---|
| | 683 | |
|---|
| | 684 | if($market->getRooms()>0): |
|---|
| | 685 | $pdf->SetX(125); |
|---|
| | 686 | $pdf->Cell(0,5,ucfirst(__('bedrooms')),0,0,'L'); |
|---|
| | 687 | $pdf->Cell(0,5,$market->getRooms(),0,0,'R'); |
|---|
| | 688 | $pdf->Ln($ln_texte); |
|---|
| | 689 | endif; |
|---|
| | 690 | |
|---|
| | 691 | if($market->getBathrooms()>0): |
|---|
| | 692 | $pdf->SetX(125); |
|---|
| | 693 | $pdf->Cell(0,5,ucfirst(__('bathroom')),0,0,'L'); |
|---|
| | 694 | $pdf->Cell(0,5,$market->getBathrooms(),0,0,'R'); |
|---|
| | 695 | $pdf->Ln($ln_texte); |
|---|
| | 696 | endif; |
|---|
| | 697 | |
|---|
| | 698 | if($market->getCarparksBasement()>0): |
|---|
| | 699 | $pdf->SetX(125); |
|---|
| | 700 | $pdf->Cell(0,5,ucfirst(__('parking sous-sol')),0,0,'L'); |
|---|
| | 701 | $pdf->Cell(0,5,$market->getCarparksBasement(),0,0,'R'); |
|---|
| | 702 | $pdf->Ln($ln_texte); |
|---|
| | 703 | endif; |
|---|
| | 704 | |
|---|
| | 705 | if($market->getCarparks()>0): |
|---|
| | 706 | $pdf->SetX(125); |
|---|
| | 707 | $pdf->Cell(0,5,ucfirst(__('parking')),0,0,'L'); |
|---|
| | 708 | $pdf->Cell(0,5,$market->getCarparks(),0,0,'R'); |
|---|
| | 709 | $pdf->Ln($ln_texte); |
|---|
| | 710 | endif; |
|---|
| | 711 | |
|---|
| | 712 | if($market->getCarparksOut()>0): |
|---|
| | 713 | $pdf->SetX(125); |
|---|
| | 714 | $pdf->Cell(0,5,ucfirst(__('parking dehors')),0,0,'L'); |
|---|
| | 715 | $pdf->Cell(0,5,$market->getCarparksOut(),0,0,'R'); |
|---|
| | 716 | $pdf->Ln($ln_texte); |
|---|
| | 717 | endif; |
|---|
| | 718 | |
|---|
| | 719 | if($market->getState()): |
|---|
| | 720 | $pdf->SetX(125); |
|---|
| | 721 | $pdf->Cell(0,5,ucfirst(__('state')),0,0,'L'); |
|---|
| | 722 | $pdf->Cell(0,5,$market->getState(),0,0,'R'); |
|---|
| | 723 | $pdf->Ln($ln_texte); |
|---|
| | 724 | endif; |
|---|
| | 725 | |
|---|
| | 726 | if($market->getSwimmingpool()): |
|---|
| | 727 | $pdf->SetX(125); |
|---|
| | 728 | $pdf->Cell(0,5,ucfirst(__('swimming pool')),0,0,'L'); |
|---|
| | 729 | $pdf->Cell(0,5,ucfirst(__('yes')),0,0,'R'); |
|---|
| | 730 | $pdf->Ln($ln_texte); |
|---|
| | 731 | endif; |
|---|
| | 732 | |
|---|
| | 733 | if($market->getStandingType()): |
|---|
| | 734 | $pdf->SetX(125); |
|---|
| | 735 | $pdf->Cell(0,5,ucfirst(__('standing')),0,0,'L'); |
|---|
| | 736 | $pdf->Cell(0,5,$market->getStandingType(),0,0,'R'); |
|---|
| | 737 | $pdf->Ln($ln_texte); |
|---|
| | 738 | endif; |
|---|
| | 739 | |
|---|
| | 740 | if($market->getLandTax() || $market->getCosts()): |
|---|
| | 741 | $pdf->Ln($ln_texte); |
|---|
| | 742 | $pdf->SetTextColor(0,103,179); |
|---|
| | 743 | $pdf->SetFont('Vera','',12); |
|---|
| | 744 | $pdf->SetFillColor(220); |
|---|
| | 745 | $pdf->SetDrawColor(150); |
|---|
| | 746 | $pdf->SetX(125); |
|---|
| | 747 | $pdf->Cell(0,5,ucfirst(__('fees')),1,0,'L',1); |
|---|
| | 748 | $pdf->SetFont('Vera','',$police['texte']); |
|---|
| | 749 | $pdf->SetTextColor(0,0,0); |
|---|
| | 750 | endif; |
|---|
| | 751 | |
|---|
| | 752 | $pdf->Ln(7); |
|---|
| | 753 | if($market->getLandTax()): |
|---|
| | 754 | $pdf->SetX(125); |
|---|
| | 755 | $pdf->Cell(0,5,ucfirst(__('ad valorem tax')),0,0,'L'); |
|---|
| | 756 | $pdf->Cell(0,5,$market->getLandTax().' â¬',0,0,'R'); |
|---|
| | 757 | $pdf->Ln($ln_texte); |
|---|
| | 758 | endif; |
|---|
| | 759 | if($market->getCosts()): |
|---|
| | 760 | $pdf->SetX(125); |
|---|
| | 761 | $charge_txt = ucfirst(__('fees')); |
|---|
| | 762 | $pdf->Cell(0,5,$charge_txt,0,0,'L'); |
|---|
| | 763 | $pdf->Cell(0,5,$market->getCosts().' â¬',0,0,'R'); |
|---|
| | 764 | $pdf->Ln($ln_texte); |
|---|
| | 765 | endif; |
|---|
| | 766 | $positionYcharges = $pdf->getY(); |
|---|
| | 767 | |
|---|
| | 768 | // pictures |
|---|
| | 769 | $pdf->SetFont('Vera','',12); |
|---|
| | 770 | $pdf->Ln(12); |
|---|
| | 771 | $pdf->setY(-95); |
|---|
| | 772 | $c = new Criteria(); |
|---|
| | 773 | $criterion = $c->getNewCriterion(PicturePeer::DEFAULT_PICTURE, null); |
|---|
| | 774 | $criterion->addOr($c->getNewCriterion(PicturePeer::DEFAULT_PICTURE, 0)); |
|---|
| | 775 | $c->add($criterion); |
|---|
| | 776 | $c->add(PicturePeer::MARKET_ID, $market->getId()); |
|---|
| | 777 | $c->addAscendingOrderByColumn(PicturePeer::RANK); |
|---|
| | 778 | $c->setLimit(3); |
|---|
| | 779 | $pictures = PicturePeer::doSelect($c); |
|---|
| | 780 | $i=0; |
|---|
| | 781 | foreach($pictures as $picture): |
|---|
| | 782 | $path = sfConfig::get('sf_upload_dir').'/market_pictures/'.$market->getId().'/'; |
|---|
| | 783 | $img_sizes = getimagesize($path.$picture->getName().'_400.'.$picture->getFormat()); |
|---|
| | 784 | $img_l = $img_sizes[0]; |
|---|
| | 785 | $img_h = $img_sizes[1]; |
|---|
| | 786 | $pict_h = 0; |
|---|
| | 787 | if($img_sizes[0]>$img_sizes[1]): |
|---|
| | 788 | $pict_l = 61; |
|---|
| | 789 | $pict_h = $img_h/$img_l*$pict_l; |
|---|
| | 790 | else: |
|---|
| | 791 | $pict_h = 46; |
|---|
| | 792 | $pict_l = $img_l/$img_h*$pict_h; |
|---|
| | 793 | endif; |
|---|
| | 794 | $pdf->Image($path.$picture->getName().'_400.'.$picture->getFormat(), 10+$i*64, $pdf->getY(), $pict_l, $pict_h); |
|---|
| | 795 | $i++; |
|---|
| | 796 | endforeach; |
|---|
| | 797 | $pdf->setX(10); |
|---|
| | 798 | endif; |
|---|
| | 799 | |
|---|
| | 800 | //fiche vitrine |
|---|
| | 801 | if($this->getRequestParameter('vitrine')=='true'): |
|---|
| | 802 | |
|---|
| | 803 | endif; |
|---|
| | 804 | |
|---|
| | 805 | //mosaique photos |
|---|
| | 806 | if($this->getRequestParameter('pictures')!='false' && ($this->getRequestParameter('pictures')==true || $this->getRequestParameter('pictures')==1)): |
|---|
| | 807 | define('X_INIT',9.6); |
|---|
| | 808 | define('Y_INIT',60); |
|---|
| | 809 | define('IMAGE_WIDTH',90); |
|---|
| | 810 | define('IMAGE_HEIGHT',90); |
|---|
| | 811 | define('MARGE_X',9.6); |
|---|
| | 812 | define('MARGE_Y',5); |
|---|
| | 813 | function getCoordonnees($type,$nb,$tab_co,$img,$hauteur_max) |
|---|
| | 814 | { |
|---|
| | 815 | if($type==4): |
|---|
| | 816 | if($nb==1){ |
|---|
| | 817 | $tab_co['y'] = Y_INIT; |
|---|
| | 818 | $tab_co['x'] = X_INIT; |
|---|
| | 819 | } else if($nb%2==0) { |
|---|
| | 820 | $tab_co['y'] = $tab_co['y']; |
|---|
| | 821 | $tab_co['x'] = X_INIT+IMAGE_WIDTH+MARGE_X; |
|---|
| | 822 | } else { |
|---|
| | 823 | $tab_co['y'] = $tab_co['y']+$hauteur_max+MARGE_Y; |
|---|
| | 824 | $tab_co['x'] = X_INIT; |
|---|
| | 825 | } |
|---|
| | 826 | endif; |
|---|
| | 827 | $img_size = resizePicture($img,IMAGE_WIDTH,IMAGE_HEIGHT); |
|---|
| | 828 | $tab_co['width'] = $img_size['width']; |
|---|
| | 829 | $tab_co['height'] = $img_size['height']; |
|---|
| | 830 | |
|---|
| | 831 | $tab_co['x_decal'] = 0; |
|---|
| | 832 | $tab_co['y_decal'] = 0; |
|---|
| | 833 | if($tab_co['width'] < IMAGE_WIDTH) |
|---|
| | 834 | $tab_co['x_decal'] = ((IMAGE_WIDTH-$tab_co['width'])/2); |
|---|
| | 835 | if($tab_co['height'] < IMAGE_HEIGHT) |
|---|
| | 836 | $tab_co['y_decal'] = ((IMAGE_HEIGHT-$tab_co['height'])/2); |
|---|
| | 837 | return $tab_co; |
|---|
| | 838 | } |
|---|
| | 839 | |
|---|
| | 840 | function resizePicture($img,$width,$height) |
|---|
| | 841 | { |
|---|
| | 842 | $img_sizes = getimagesize($img); |
|---|
| | 843 | $img_width = $img_sizes[0]; |
|---|
| | 844 | $img_height = $img_sizes[1]; |
|---|
| | 845 | if($img_width>$img_height){ |
|---|
| | 846 | $img_size['width']=$width; |
|---|
| | 847 | $percent = ($img_width / $img_size['width']); |
|---|
| | 848 | $img_size['height'] = ($img_height / $percent); |
|---|
| | 849 | } |
|---|
| | 850 | else if($img_width<$img_height){ |
|---|
| | 851 | $img_size['height']=$height; |
|---|
| | 852 | $percent = ($img_height / $img_size['height']); |
|---|
| | 853 | $img_size['width'] = ($img_width / $percent); |
|---|
| | 854 | } |
|---|
| | 855 | else{ |
|---|
| | 856 | $img_size['height'] = $height; |
|---|
| | 857 | $img_size['width'] = $width; |
|---|
| | 858 | } |
|---|
| | 859 | return $img_size; |
|---|
| | 860 | } |
|---|
| | 861 | |
|---|
| | 862 | |
|---|
| | 863 | $pdf->AddPage(); |
|---|
| | 864 | $pdf->setX(X_INIT); |
|---|
| | 865 | $pdf->setY(Y_INIT); |
|---|
| | 866 | //pictures list |
|---|
| | 867 | $c = new Criteria(); |
|---|
| | 868 | $c->add(PicturePeer::MARKET_ID, $market->getId()); |
|---|
| | 869 | $c->addDescendingOrderByColumn(PicturePeer::DEFAULT_PICTURE); |
|---|
| | 870 | $c->addAscendingOrderByColumn(PicturePeer::RANK); |
|---|
| | 871 | $c->addAscendingOrderByColumn(PicturePeer::ID); |
|---|
| | 872 | $pictures = PicturePeer::doSelect($c); |
|---|
| | 873 | $path = sfConfig::get('sf_upload_dir').'/market_pictures/'.$market->getId().'/'; |
|---|
| | 874 | $nb_total = 4; |
|---|
| | 875 | $nb = 0; |
|---|
| | 876 | $type = 4; |
|---|
| | 877 | $tab_co = array(); |
|---|
| | 878 | $hauteur_max = 0; |
|---|
| | 879 | foreach($pictures as $picture): |
|---|
| | 880 | $nb_total++; |
|---|
| | 881 | $nb++; |
|---|
| | 882 | if($nb > $type): |
|---|
| | 883 | $pdf->SetY(250); |
|---|
| | 884 | if($nb > $type): |
|---|
| | 885 | $nb = 1; |
|---|
| | 886 | $pdf->AddPage(); |
|---|
| | 887 | $hauteur_max = 0; |
|---|
| | 888 | $tab_co['y'] = Y_INIT; |
|---|
| | 889 | $tab_co['x'] = X_INIT; |
|---|
| | 890 | endif; |
|---|
| | 891 | endif; |
|---|
| | 892 | $tab_co = getCoordonnees($type,$nb,$tab_co,$path.$picture->getName().'_400.'.$pictures[0]->getFormat(),$hauteur_max); |
|---|
| | 893 | if($tab_co['height']>$hauteur_max) $hauteur_max = $tab_co['height']+$tab_co['y_decal']; |
|---|
| | 894 | $pdf->Image($path.$picture->getName().'_400.'.$pictures[0]->getFormat(), $tab_co['x']+$tab_co['x_decal'], $tab_co['y']+$tab_co['y_decal'], $tab_co['width'],$tab_co['height']); |
|---|
| | 895 | $pdf->SetDrawColor(145,145,145); |
|---|
| | 896 | $pdf->Rect(($tab_co['x']+$tab_co['x_decal'])-1, ($tab_co['y']+$tab_co['y_decal'])-1, $tab_co['width']+2, $tab_co['height']+2); |
|---|
| | 897 | endforeach; |
|---|
| | 898 | |
|---|
| | 899 | endif; |
|---|
| | 900 | endforeach; |
|---|
| | 901 | |
|---|
| | 902 | if($this->getRequestParameter('choice') == 'print'): |
|---|
| | 903 | //Headers |
|---|
| | 904 | $this->getResponse()->clearHttpHeaders(); |
|---|
| | 905 | $this->getResponse()->addCacheControlHttpHeader('Cache-control', 'private'); |
|---|
| | 906 | $this->getResponse()->setContentType('application/pdf', true); |
|---|
| | 907 | $this->getResponse()->setHttpHeader('content-transfer-encoding', 'binary', true); |
|---|
| | 908 | $this->getResponse()->setHttpHeader('Content-Disposition','inline; filename=Fiche-'.$market->getId().'.pdf', true); |
|---|
| | 909 | $this->getResponse()->sendHttpHeaders(); |
|---|
| | 910 | $pdf_output = $pdf->Output(); |
|---|
| | 911 | $this->getUser()->setCulture($lang); |
|---|
| | 912 | echo $pdf_output; |
|---|
| | 913 | exit(); |
|---|
| | 914 | elseif($this->getRequestParameter('choice') == 'mail'): |
|---|
| | 915 | $contact = ContactPeer::retrieveByPk($this->getRequestParameter('contact_id')); |
|---|
| | 916 | $this->forward404Unless($contact); |
|---|
| | 917 | if(!$contact->getMail()): |
|---|
| | 918 | $contact->setMail($this->getRequestParameter('mail')); |
|---|
| | 919 | $contact->save(); |
|---|
| | 920 | endif; |
|---|
| | 921 | $mail = new sfMail(); |
|---|
| | 922 | $mail->setBody($this->getRequestParameter('body')); |
|---|
| | 923 | $mail->setSubject($this->getRequestParameter('subject')); |
|---|
| | 924 | $mail->addAddress($contact->getMail()); |
|---|
| | 925 | $mail->addBcc($this->getUser()->getSubscriber()->getMail()); |
|---|
| | 926 | $mail->setSender($this->getUser()->getSubscriber()->getMail()); |
|---|
| | 927 | $mail->setFrom($this->getUser()->getSubscriber().' <'.$this->getUser()->getSubscriber()->getMail().'>'); |
|---|
| | 928 | $mail->setCharset('utf-8'); |
|---|
| | 929 | $mail->addStringAttachment($pdf->Output('', 'S'), 'Selection.pdf'); |
|---|
| | 930 | $mail->send(); |
|---|
| | 931 | |
|---|
| | 932 | // historique |
|---|
| | 933 | $history = new History(); |
|---|
| | 934 | $history->setUserRead(1); |
|---|
| | 935 | $history->setContactId($contact->getId()); |
|---|
| | 936 | $history->setSalesId($sales->getId()); |
|---|
| | 937 | $history->setTypeId(2); |
|---|
| | 938 | $history->setObjet($this->getRequestParameter('subject')); |
|---|
| | 939 | $history->setContent($this->getRequestParameter('body')); |
|---|
| | 940 | $history->setCreatedBy($this->getUser()->getSubscriberId()); |
|---|
| | 941 | $history->setUpdatedBy($this->getUser()->getSubscriberId()); |
|---|
| | 942 | $history->save(); |
|---|
| | 943 | |
|---|
| | 944 | // update all contact searches |
|---|
| | 945 | $c = new Criteria(); |
|---|
| | 946 | $c->add(SearchPeer::CONTACT_ID, $contact->getId()); |
|---|
| | 947 | $searchList = SearchPeer::doSelect($c); |
|---|
| | 948 | foreach($searchList as $search): |
|---|
| | 949 | $search->setUpdatedAt(date('Y-m-d')); |
|---|
| | 950 | $search->setUpdatedBy($this->getUser()->getSubscriberId()); |
|---|
| | 951 | $search->save(); |
|---|
| | 952 | endforeach; |
|---|
| | 953 | $this->getUser()->setCulture($lang); |
|---|
| | 954 | $this->setTemplate('mail_send'); |
|---|
| | 955 | endif; |
|---|
| | 956 | } |
|---|