Changeset 26275


Ignore:
Timestamp:
06/04/10 01:55:45 (7 years ago)
Author:
flack
Message:

some fixes & cleanups for import script, refs #1808

Location:
branches/ragnaroek/midcom
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/ragnaroek/midcom/org.openpsa.contacts/exec/convert_to_8_09_9.php

    r26257 r26275  
    77
    88$_MIDCOM->componentloader->load('org.openpsa.invoices');
    9 $billing_attributs = array('invoiceStreet' => 'street', 'invoiceCity' => 'city' , 'invoicePostcode' => 'postcode' ,
     9$billing_attributes = array('invoiceStreet' => 'street', 'invoiceCity' => 'city' , 'invoicePostcode' => 'postcode' ,
    1010    'invoiceCountry' => 'country' , 'vatNo' => 'vatNo' , 'invoiceDue' =>'due' ,
    1111    'invoiceVat' => 'vat' , 'invoiceDistribution' => 'delivery' , 'official' => 'recipient');
     
    1717
    1818$keys = $mc->list_keys();
    19 foreach($keys as $key => $empty)
     19foreach ($keys as $key => $empty)
    2020{
    2121    $keys[$key] = $mc->get_subkey($key ,'linkGuid');
    2222}
    2323
    24 
    2524$qb = org_openpsa_contacts_group_dba::new_query_builder();
    26 if(!empty($keys))
     25if (!empty($keys))
    2726{
    28     $qb->add_constraint('guid' , 'NOT IN' , $keys);
     27    $qb->add_constraint('guid', 'NOT IN', $keys);
    2928}
    3029
    3130$qb->begin_group('OR');
    32 foreach($billing_attributs as $org_attribute_name => $billingData_attribute_name)
     31foreach ($billing_attributes as $org_attribute_name => $billingData_attribute_name)
    3332{
    34     $qb->add_constraint($org_attribute_name , '<>' , '');
     33    $qb->add_constraint($org_attribute_name, '<>', '');
    3534}
    3635$qb->end_group();
     
    3837$organizations = $qb->execute();
    3938
    40 foreach($organizations as $org)
     39foreach ($organizations as $org)
    4140{
    42     echo "Starting Migration of Organization :" . $org->official . " (id: " . $org->id . ")\n";
    43     //check if there is already invoice_data
    44     $qb_invoice_data = org_openpsa_invoices_billing_data_dba::new_query_builder();
    45     $qb_invoice_data->add_constraint('linkGuid' , '=' , $org->guid);
    46     $result = $qb_invoice_data->execute();
    47     if(count($result) > 0)
     41    echo "Starting Migration of Organization: " . $org->official . " (ID: " . $org->id . ")\n";
     42
     43    $new_invoice_data = new org_openpsa_invoices_billing_data_dba();
     44    foreach ($billing_attributes as $org_attribute_name => $billingData_attribute_name)
    4845    {
    49         echo "Organization :" . $org->official . " (id: " . $org->id . ")  has already invoice_data set\n";
     46        echo "Copying " . $org_attribute_name ." to " . $billingData_attribute_name . " \n";
     47        $new_invoice_data->$billingData_attribute_name = $org->$org_attribute_name;
     48    }
     49
     50    //use contact address is empty
     51    if (empty($org->invoiceStreet))
     52    {
     53        $new_invoice_data->useContactAddress = true;
    5054    }
    5155    else
    5256    {
    53         $new_invoice_data = new org_openpsa_invoices_billing_data_dba();
    54         foreach($billing_attributs as $org_attribute_name => $billingData_attribute_name)
    55         {
    56             echo "Copying " . $org_attribute_name ." to " . $billingData_attribute_name . " \n";
    57             $new_invoice_data->$billingData_attribute_name = $org->$org_attribute_name;
    58         }
    59         //use contact address is empty
    60         if(empty($org->invoiceStreet))
    61         {
    62             $new_invoice_data->useContactAdress = true;
    63         }
     57        $new_invoice_data->useContactAddress = false;
     58    }
    6459
    65         $new_invoice_data->linkGuid = $org->guid;
    66         $new_invoice_data->useContactAddress = false;
     60    $new_invoice_data->linkGuid = $org->guid;
    6761
    68         if($new_invoice_data->create())
    69         {
    70             echo "Created billing_data for Organization \n\n";
    71         }
    72         else
    73         {
    74             echo "Couldn't create billing_data for Organization !!!\n\n";
    75             echo "Aborting \n";
    76             flush();
    77             break;
    78         }
     62    if ($new_invoice_data->create())
     63    {
     64        echo "Created billing_data for Organization \n\n";
     65        flush();
    7966    }
    80     flush();
     67    else
     68    {
     69        echo "Couldn't create billing_data for Organization !!!\n\n";
     70        echo "Aborting \n";
     71        flush();
     72        break;
     73    }
    8174}
    8275
  • branches/ragnaroek/midcom/org.openpsa.invoices/config/mgdschema.xml

    r26261 r26275  
    7575        <property name="due" type="unsigned integer" />
    7676       
    77         <property name="useContactAddress" type="bool" />
     77        <property name="useContactAddress" type="boolean" />
    7878        <!-- guid of the object the billing data belongs to -->
    7979        <property name="linkGuid" type="string" />
Note: See TracChangeset for help on using the changeset viewer.