fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [7040] Merge 7036:7039 from trunk


From: Sigurd Nes
Subject: [Fmsystem-commits] [7040] Merge 7036:7039 from trunk
Date: Wed, 23 Feb 2011 12:29:49 +0000

Revision: 7040
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7040
Author:   sigurdne
Date:     2011-02-23 12:29:49 +0000 (Wed, 23 Feb 2011)
Log Message:
-----------
Merge 7036:7039 from trunk

Modified Paths:
--------------
    branches/Version-1_0-branch/property/inc/class.solocation.inc.php
    branches/Version-1_0-branch/property/inc/class.uilocation.inc.php
    branches/Version-1_0-branch/rental/inc/class.socomposite.inc.php
    branches/Version-1_0-branch/rental/inc/class.uimakepdf.inc.php
    
branches/Version-1_0-branch/rental/templates/base/pdf/rental_contract_form_personalbolig.php

Property Changed:
----------------
    branches/Version-1_0-branch/


Property changes on: branches/Version-1_0-branch
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035
   + 
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035,7037-7039

Modified: branches/Version-1_0-branch/property/inc/class.solocation.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.solocation.inc.php   
2011-02-23 12:28:32 UTC (rev 7039)
+++ branches/Version-1_0-branch/property/inc/class.solocation.inc.php   
2011-02-23 12:29:49 UTC (rev 7040)
@@ -1184,6 +1184,7 @@
 
                function add($location,$values_attribute = array(),$type_id='')
                {
+                       $receipt = array();
                        foreach ($location as $input_name => $value)
                        {
                                if($value)
@@ -1240,12 +1241,13 @@
                                }
                        }
 
+                       $receipt['location_code'] = $location['location_code'];
                        return $receipt;
                }
 
-               function edit($location='',$values_attribute='',$type_id='')
+               function edit($location,$values_attribute=array(),$type_id='')
                {
-                       //_debug_array($values_attribute);
+                       $receipt = array();
                        while (is_array($location) && list($input_name,$value) 
= each($location))
                        {
                                if($value)
@@ -1320,6 +1322,7 @@
                        $this->db->query($sql,__LINE__,__FILE__);
                        $this->db->transaction_commit();
                        $receipt['message'][] = array('msg'=>lang('Location %1 
has been edited',$location['location_code']));
+                       $receipt['location_code'] = $location['location_code'];
                        return $receipt;
                }
 

Modified: branches/Version-1_0-branch/property/inc/class.uilocation.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uilocation.inc.php   
2011-02-23 12:28:32 UTC (rev 7039)
+++ branches/Version-1_0-branch/property/inc/class.uilocation.inc.php   
2011-02-23 12:29:49 UTC (rev 7040)
@@ -1627,6 +1627,7 @@
                        $parent                         = 
phpgw::get_var('parent');
                        $values_attribute       = 
phpgw::get_var('values_attribute');
                        $location                       = 
explode('-',$location_code);
+                       $error_id                       = false;
 
                        if($sibling)
                        {
@@ -1712,24 +1713,23 @@
                                }
                        }
 
-
                        
$GLOBALS['phpgw']->xslttpl->add_file(array('location','attributes_form'));
 
                        if ($values)
                        {
                                for ($i=1; $i<($type_id+1); $i++)
                                {
-                                       if((!$values['loc' . $i]  && 
(!isset($location[($i-1)])  || !$location[($i-1)])  ) || !$values['loc' . $i])
+                                       if((!$values["loc{$i}"]  && 
(!isset($location[($i-1)])  || !$location[($i-1)])  ) || !$values["loc{$i}"])
                                        {
                                                
$receipt['error'][]=array('msg'=>lang('Please select a location %1 ID !',$i));
-                                               $error_id=true;
+                                               $error_id = true;
                                        }
 
-                                       $values['location_code'][]= 
$values['loc' . $i];
+                                       $values['location_code'][]= 
$values["loc{$i}"];
 
                                        if($i<$type_id)
                                        {
-                                               $location_parent[]= 
$values['loc' . ($i)];
+                                               $location_parent[]= 
$values["loc{$i}"];
                                        }
                                }
 
@@ -1772,12 +1772,10 @@
                                if($values['location_code'] && !$location_code)
                                {
                                        
if($this->bo->check_location($values['location_code'],$type_id))
-
-
                                        {
                                                
$receipt['error'][]=array('msg'=>lang('This location is already registered!') . 
'[ '.$values['location_code'].' ]');
                                                $error_location_id=true;
-                                               $error_id=true;
+                                               $error_id = true;
                                        }
                                }
 
@@ -1792,21 +1790,23 @@
                                                
$receipt['error'][]=array('msg'=>lang('Please select change type'));
                                        }
                                }
-                               elseif(!$location_code && !$error_id )
-                               {
-                                       $location_code=$values['location_code'];
-                               }
 
                                if(!isset($receipt['error']))
                                {
                                        $receipt = 
$this->bo->save($values,$values_attribute,$action,$type_id,isset($location_parent)?$location_parent:'');
+                                       $error_id = 
isset($receipt['location_code']) && $receipt['location_code'] ? false : true;
+                                       $location_code = 
$receipt['location_code'];
                                }
                                else
                                {
                                        if(isset($location_parent) && 
$location_parent)
                                        {
-                                               
$location_code_parent=implode("-", $location_parent);
+                                               
$location_code_parent=implode('-', $location_parent);
                                                $values = 
$this->bo->read_single($location_code_parent);
+
+                                               $values['attributes']   = 
$this->bo->find_attribute(".location.{$this->type_id}");
+                                               $values                         
        = $this->bo->prepare_attribute($values, ".location.{$this->type_id}");
+
                                                /* restore date from posting */
                                                
if(isset($insert_record['extra']) && is_array($insert_record['extra']))
                                                {
@@ -1819,7 +1819,7 @@
                                }
                        }
 
-                       if(!isset($error_id) && $location_code)
+                       if(!$error_id && $location_code)
                        {
                                $values = 
$this->bo->read_single($location_code,array('tenant_id'=>'lookup'));
 
@@ -1928,6 +1928,7 @@
 
                        $insert_record = 
$GLOBALS['phpgw']->session->appsession('insert_record','property');
 
+
                        if(!is_array($insert_record))
                        {
                                $insert_record = array();

Modified: branches/Version-1_0-branch/rental/inc/class.socomposite.inc.php
===================================================================
--- branches/Version-1_0-branch/rental/inc/class.socomposite.inc.php    
2011-02-23 12:28:32 UTC (rev 7039)
+++ branches/Version-1_0-branch/rental/inc/class.socomposite.inc.php    
2011-02-23 12:29:49 UTC (rev 7040)
@@ -82,14 +82,18 @@
                }
                switch($filters['has_contract']){
                        case "has_contract":
-                               $filter_clauses[] = "(NOT 
rental_contract_composite.contract_id IS NULL AND (NOT 
rental_contract.date_start IS NULL AND rental_contract.date_start > 
$availability_date_from OR rental_contract.date_start < $availability_date_to 
AND (rental_contract.date_end IS NULL OR (rental_contract.date_end > 
$availability_date_from OR rental_contract.date_end < 
$availability_date_to))))";
+                               $filter_clauses[] = "(NOT 
rental_contract_composite.contract_id IS NULL AND NOT((NOT 
rental_contract.date_start IS NULL AND ( rental_contract.date_start < 
$availability_date_from AND rental_contract.date_end < $availability_date_from) 
OR (rental_contract.date_end IS NULL OR ( rental_contract.date_start > 
$availability_date_to AND rental_contract.date_end > 
$availability_date_to)))))";
+                               //$filter_clauses[] = "(NOT 
rental_contract_composite.contract_id IS NULL AND (NOT 
rental_contract.date_start IS NULL AND (NOT rental_contract.date_start < 
$availability_date_from AND NOT rental_contract.date_end < 
$availability_date_from) OR (rental_contract.date_end IS NULL OR (NOT 
rental_contract.date_start > $availability_date_to AND NOT 
rental_contract.date_end > $availability_date_to))))";
+                               //$filter_clauses[] = "(NOT 
rental_contract_composite.contract_id IS NULL AND (NOT 
rental_contract.date_start IS NULL AND rental_contract.date_start < 
$availability_date_from OR rental_contract.date_end < $availability_date_from 
AND (rental_contract.date_end IS NULL OR (rental_contract.date_start > 
$availability_date_to AND rental_contract.date_end > $availability_date_to))))";
                                //$filter_clauses[] = "(NOT 
rental_contract_composite.contract_id IS NULL AND (NOT 
rental_contract.date_start IS NULL AND rental_contract.date_start < 
$availability_date_from AND ((rental_contract.date_end IS NULL OR (NOT 
rental_contract.date_end IS NULL AND rental_contract.date_end > 
$availability_date_from)) OR (rental_contract.date_start > 
$availability_date_to AND (rental_contract.date_end IS NULL OR (NOT 
rental_contract.date_end IS NULL AND rental_contract.date_end < 
$availability_date_to))))))";
                                //$filter_clauses[] = "(NOT 
rental_contract_composite.contract_id IS NULL AND (NOT 
rental_contract.date_start IS NULL AND rental_contract.date_start < 
$availability_date_from AND (rental_contract.date_end IS NULL OR (NOT 
rental_contract.date_end IS NULL AND rental_contract.date_end > 
$availability_date_from))))";
                                $special_query=true;
                                break;
                        case "has_no_contract":
                                //$filter_clauses[] = 
"(rental_contract_composite.contract_id IS NULL OR NOT rental_composite.id IN 
(SELECT rental_composite.id FROM rental_composite LEFT JOIN  
rental_contract_composite ON (rental_contract_composite.composite_id = 
rental_composite.id) LEFT JOIN  rental_contract ON (rental_contract.id = 
rental_contract_composite.contract_id) WHERE 1=1 AND rental_composite.is_active 
= TRUE AND (NOT rental_contract_composite.contract_id IS NULL AND (NOT 
rental_contract.date_start IS NULL AND rental_contract.date_start < 
$availability_date_from AND (rental_contract.date_end IS NULL OR (NOT 
rental_contract.date_end IS NULL AND rental_contract.date_end > 
$availability_date_from))))))";
-                               $filter_clauses[] = 
"(rental_contract_composite.contract_id IS NULL OR NOT rental_composite.id IN 
(SELECT rental_composite.id FROM rental_composite LEFT JOIN  
rental_contract_composite ON (rental_contract_composite.composite_id = 
rental_composite.id) LEFT JOIN  rental_contract ON (rental_contract.id = 
rental_contract_composite.contract_id) WHERE 1=1 AND rental_composite.is_active 
= TRUE AND (NOT rental_contract_composite.contract_id IS NULL AND (NOT 
rental_contract.date_start IS NULL AND ((rental_contract.date_start > 
$availability_date_from OR rental_contract.date_start < $availability_date_to 
AND (NOT rental_contract.date_end IS NULL AND rental_contract.date_end > 
$availability_date_from OR rental_contract.date_end < 
$availability_date_to)))))))";
+                               //$filter_clauses[] = 
"(rental_contract_composite.contract_id IS NULL OR NOT rental_composite.id IN 
(SELECT rental_composite.id FROM rental_composite LEFT JOIN  
rental_contract_composite ON (rental_contract_composite.composite_id = 
rental_composite.id) LEFT JOIN  rental_contract ON (rental_contract.id = 
rental_contract_composite.contract_id) WHERE 1=1 AND rental_composite.is_active 
= TRUE AND (NOT rental_contract_composite.contract_id IS NULL OR (NOT 
rental_contract.date_start IS NULL OR  (((rental_contract.date_start < 
$availability_date_from AND rental_contract.date_end < $availability_date_from) 
OR (NOT rental_contract.date_end IS NULL OR (rental_contract.date_start > 
$availability_date_to AND rental_contract.date_end > 
$availability_date_to))))))))";
+                               $filter_clauses[] = 
"(rental_contract_composite.contract_id IS NULL OR NOT rental_composite.id IN 
(SELECT rental_composite.id FROM rental_composite LEFT JOIN  
rental_contract_composite ON (rental_contract_composite.composite_id = 
rental_composite.id) LEFT JOIN  rental_contract ON (rental_contract.id = 
rental_contract_composite.contract_id) WHERE  NOT 
(((((rental_contract.date_start < $availability_date_from AND 
rental_contract.date_end < $availability_date_from) OR ( 
(rental_contract.date_start > $availability_date_to AND 
rental_contract.date_end > $availability_date_to))))))))";
+                               
                                $special_query=true;
                                break;
                        case "both":
@@ -155,11 +159,11 @@
                {
                        if($special_query)
                        {
-                               $cols = "DISTINCT(rental_composite.id) AS 
composite_id, rental_unit.id AS unit_id, rental_unit.location_code, 
rental_composite.name, rental_composite.has_custom_address, 
rental_composite.address_1, rental_composite.house_number, 
rental_composite.address_2, rental_composite.postcode, rental_composite.place, 
rental_composite.is_active, rental_composite.area, CASE WHEN (NOT 
rental_contract_composite.contract_id IS NULL AND (NOT 
rental_contract.date_start IS NULL AND rental_contract.date_start > 
$availability_date_from OR rental_contract.date_start < $availability_date_to 
AND (rental_contract.date_end IS NULL OR (rental_contract.date_end > 
$availability_date_from OR rental_contract.date_end < $availability_date_to)))) 
THEN 'Ikke ledig' ELSE 'Ledig' END as status";
+                               $cols = "DISTINCT(rental_composite.id) AS 
composite_id, rental_unit.id AS unit_id, rental_unit.location_code, 
rental_composite.name, rental_composite.has_custom_address, 
rental_composite.address_1, rental_composite.house_number, 
rental_composite.address_2, rental_composite.postcode, rental_composite.place, 
rental_composite.is_active, rental_composite.area, CASE WHEN (NOT 
rental_contract_composite.contract_id IS NULL AND (NOT 
rental_contract.date_start IS NULL AND (NOT (rental_contract.date_start < 
$availability_date_from AND rental_contract.date_end < 
$availability_date_from)) AND (rental_contract.date_end IS NULL OR NOT 
(rental_contract.date_start > $availability_date_to AND 
rental_contract.date_end > $availability_date_to)))) THEN 'Ikke ledig' ELSE 
'Ledig' END as status";
                        }
                        else
                        {
-                               $cols = "rental_composite.id AS composite_id, 
rental_unit.id AS unit_id, rental_unit.location_code, rental_composite.name, 
rental_composite.has_custom_address, rental_composite.address_1, 
rental_composite.house_number, rental_composite.address_2, 
rental_composite.postcode, rental_composite.place, rental_composite.is_active, 
rental_composite.area, CASE WHEN (NOT rental_contract_composite.contract_id IS 
NULL AND (NOT rental_contract.date_start IS NULL AND rental_contract.date_start 
> $availability_date_from OR rental_contract.date_start < $availability_date_to 
AND (rental_contract.date_end IS NULL OR (rental_contract.date_end > 
$availability_date_from OR rental_contract.date_end < $availability_date_to)))) 
THEN 'Ikke ledig' ELSE 'Ledig' END as status";
+                               $cols = "rental_composite.id AS composite_id, 
rental_unit.id AS unit_id, rental_unit.location_code, rental_composite.name, 
rental_composite.has_custom_address, rental_composite.address_1, 
rental_composite.house_number, rental_composite.address_2, 
rental_composite.postcode, rental_composite.place, rental_composite.is_active, 
rental_composite.area, CASE WHEN (NOT rental_contract_composite.contract_id IS 
NULL AND (NOT rental_contract.date_start IS NULL AND (NOT 
(rental_contract.date_start < $availability_date_from AND 
rental_contract.date_end < $availability_date_from)) AND 
(rental_contract.date_end IS NULL OR NOT (rental_contract.date_start > 
$availability_date_to AND rental_contract.date_end > $availability_date_to)))) 
THEN 'Ikke ledig' ELSE 'Ledig' END as status";
                        }
                }
                $dir = $ascending ? 'ASC' : 'DESC';

Modified: branches/Version-1_0-branch/rental/inc/class.uimakepdf.inc.php
===================================================================
--- branches/Version-1_0-branch/rental/inc/class.uimakepdf.inc.php      
2011-02-23 12:28:32 UTC (rev 7039)
+++ branches/Version-1_0-branch/rental/inc/class.uimakepdf.inc.php      
2011-02-23 12:29:49 UTC (rev 7040)
@@ -11,6 +11,7 @@
        phpgw::import_class('rental.soadjustment');
        phpgw::import_class('rental.soparty');
        include_class('rental', 'contract', 'inc/model/');
+       include_class('rental', 'document', 'inc/model/');
        include_class('rental', 'party', 'inc/model/');
        include_class('rental', 'composite', 'inc/model/');
        include_class('rental', 'price_item', 'inc/model/');
@@ -413,7 +414,6 @@
                 */
                public function makePDF()
                {
-                       
                        $myFile = "/opt/portico/pe/rental/tmp/testFile.html";
                        $fh = fopen($myFile, 'w') or die("can't open file");
                        $stringData = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 
4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd";>';
@@ -425,13 +425,96 @@
                        $stringData = '</div></body></html>';
                        fwrite($fh, $stringData);
                        fclose($fh);
-                       echo $_SESSION['contract_html'];
+                       //echo $_SESSION['contract_html'];
                         $_SESSION['contract_html'] = "";
                         
                        $snappy = new SnappyPdf;
                        
$snappy->setExecutable('/opt/portico/pe/rental/wkhtmltopdf-i386'); // or 
whatever else
                        
$snappy->save('/opt/portico/pe/rental/tmp/testFile.html', 
'/opt/portico/pe/rental/tmp/testFile.pdf');
+                       
+                       $contract_id = phpgw::get_var('id');
+                       //var_dump("contr: " . phpgw::get_var('id'));
+                       $pdf_file_name = 
"/opt/portico/pe/rental/tmp/testFile.pdf";
+                       //$pdf_file = fopen($pdf_file_name, 'r') or die("cannot 
open file $pdf_file_name");
+                       $this->savePDFToContract($pdf_file_name, $contract_id, 
'Kontrakt');
                }
+               
+               /*
+                * Store a contract as PDF to VFS
+                * Add generated PDF to list of contract documents
+                */
+               public function savePDFToContract($file, $contract_id, $title)
+               {
+                       //Create a document object
+                       $document = new rental_document();
+                       $document->set_title($title);
+                       
$document->set_name("Kontrakt_".strtotime(date('Y-m-d')).".pdf");
+                       $document->set_type_id(1);
+                       $document->set_contract_id($contract_id);
+                       $document->set_party_id(NULL);
+                       
+                       
+                       //Retrieve the document properties
+                       $document_properties = 
$this->get_type_and_id($document);
+                       
+                       // Move file from temporary storage to vfs
+                       $result = 
rental_sodocument::get_instance()->write_document_to_vfs
+                       (
+                               $document_properties['document_type'], 
+                               $file,
+                               $document_properties['id'],
+                               "Kontrakt_".strtotime(date('Y-m-d')).".pdf"
+                       );
+                       
+                       if($result)
+                       {
+                               
if(rental_sodocument::get_instance()->store($document))
+                               {
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'rental.uicontract.edit', 'id' => $contract_id, 'tab' => 'documents'));
+                               }
+                               else
+                               {
+                                       // Handle failure on storing document
+                                       $this->redirect($document, 
$document_properties,'','');
+                               }
+                       }
+                       else
+                       {
+                               //Handle vfs failure to store document
+                               $this->redirect($document, 
$document_properties,'','');
+                       }
+                       return false;
+               }
+               
+               /**
+                * Utility method for finding out whether a document is bound 
to a
+                * contract or a party.
+                * 
+                * @param $document     the given document
+                * @return name/value array ('document_type','id')
+                */
+               private function get_type_and_id($document)
+               {
+                       $document_type;
+                       $id;
+                       $contract_id = $document->get_contract_id();
+                       $party_id = $document->get_party_id();
+                       if(isset($contract_id) && $contract_id > 0)
+                       {
+                               $document_type = 
rental_sodocument::$CONTRACT_DOCUMENTS;
+                               $id = $contract_id;
+                       } 
+                       else if(isset($party_id) && $party_id > 0)
+                       {
+                               $document_type = 
rental_sodocument::$PARTY_DOCUMENTS;
+                               $id = $party_id;
+                       }
+                       return array
+                       (
+                               'document_type' => $document_type,
+                               'id' => $id
+                       );
+               }
 
                /**
                 * Edit a contract

Modified: 
branches/Version-1_0-branch/rental/templates/base/pdf/rental_contract_form_personalbolig.php
===================================================================
--- 
branches/Version-1_0-branch/rental/templates/base/pdf/rental_contract_form_personalbolig.php
        2011-02-23 12:28:32 UTC (rev 7039)
+++ 
branches/Version-1_0-branch/rental/templates/base/pdf/rental_contract_form_personalbolig.php
        2011-02-23 12:29:49 UTC (rev 7040)
@@ -506,7 +506,7 @@
 <input type="submit" value="Rediger" name="edit"> 
 </form>
 
-<form action="<?php echo(html_entity_decode(self::link(array('menuaction' => 
'rental.uimakepdf.makePDF', 'id' => $value['id'], 'initial_load' => 
'no'))));?>" method="post">
+<form action="<?php echo(html_entity_decode(self::link(array('menuaction' => 
'rental.uimakepdf.makePDF', 'id' => $contract->get_id(), 'initial_load' => 
'no'))));?>" method="post">
 <input type="submit" value="Lagre som PDF" name="make_PDF" /> 
 
 </form>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]