/**
  * @return void
  * @author Carlos Escribano <*****@*****.**>
  **/
 public function save($con = null)
 {
     parent::save();
     $currency_decimals = sfConfig::get('app_currency_decimals', array());
     foreach ($this->getValues() as $key => $value) {
         switch ($key) {
             case 'company_logo':
                 if ("on" == $this->getValue('company_logo_delete') && is_file($old = sfConfig::get('sf_upload_dir') . DIRECTORY_SEPARATOR . PropertyTable::get('company_logo'))) {
                     @unlink($old);
                     PropertyTable::set('company_logo', null);
                 }
                 if ($value) {
                     $fname = $value->generateFilename();
                     $value->save(sfConfig::get('sf_upload_dir') . DIRECTORY_SEPARATOR . $fname);
                     PropertyTable::set('company_logo', $fname);
                 }
                 break;
             case 'company_logo_delete':
                 break;
             case 'currency':
                 PropertyTable::set('currency_decimals', array_key_exists($value, $currency_decimals) ? $currency_decimals[$value] : 2);
                 PropertyTable::set('currency', $value);
                 break;
             case 'seriess':
             case 'taxes':
                 break;
             default:
                 PropertyTable::set($key, $value);
                 break;
         }
     }
 }
示例#2
0
 /**
  * undocumented function
  *
  * @return void
  * @author JoeZ99 <*****@*****.**>
  **/
 public function executeSiwappModules(sfWebRequest $request)
 {
     $user = $this->getUser();
     $i18n = $this->getContext()->getI18N();
     $form = new SiwappModulesForm();
     if ($request->isMethod('post')) {
         $form->bind($request->getParameter($form->getName()));
         if ($form->isValid()) {
             $config = $request->getParameter($form->getName());
             if (!(isset($config['siwapp_modules']) and $smodules = $config['siwapp_modules'])) {
                 $smodules = array();
             }
             PropertyTable::set('siwapp_modules', $smodules);
             $user->info($i18n->__('Your settings were successfully saved.'));
             $user->loadUserSettings();
             $this->redirect('@siwapp_modules');
         } else {
             $user->error($i18n->__('Settings could not be saved'), false);
         }
     }
     $this->form = $form;
 }
示例#3
0
$invoice->setSeriesId('1');
$invoice->save();
$t->is($invoice->number, 9, 'When changing number series, the inv number changes');
$invoice->setSeriesId('2');
$invoice->save();
$t->is($invoice->number, 5, 'When changing back it gets the next maximun number available');
// checks savings with modified customer data
$t->diag('customers mod available: checking that moddified cust data does not alter customer object itself');
$invoice = Doctrine::getTable('Invoice')->findOneBy('CustomerName', 'Smith and Co.');
$invoice->customer_email = '*****@*****.**';
$invoice->save();
$t->is($invoice->customer_id, $customer_id, "customer id not changed");
$c = Doctrine::getTable('Customer')->findOneById($customer_id);
$t->is($c->name . $c->email, 'Smith and Co.jody_nichols@example.com', 'Customer object is not modified');
$t->diag('customers mod not available: checking that moddified cust data in the invoice alter customer object itself');
PropertyTable::set('siwapp_modules', array('products', 'estimates'));
$invoice->customer_email = '*****@*****.**';
$invoice->save();
$c = Doctrine::getTable('Customer')->findOneById($customer_id);
$t->is($c->name . $c->email, 'Smith and Co.test2@testmail.com', 'Customer object is modified');
PropertyTable::set('siwapp_modules', array('customers', 'products', 'estimates'));
$t->diag('checking that changing customer name changes customer');
$invoice->customer_name = 'Rouster and Sideways';
$invoice->save();
$c = Doctrine::getTable('Customer')->findOneById($invoice->customer_id);
$t->is($c->name_slug, CustomerTable::slugify($invoice->customer_name), 'A different customer object is associated');
$t->diag('checking that db-new customer name creates a new customer');
$invoice->customer_name = 'New Rouster and Sideways';
$invoice->save();
$c = Doctrine::getTable('Customer')->findOneByNameSlug(CustomerTable::slugify($invoice->customer_name));
$t->is($c->name, $invoice->customer_name, 'New Customer created');
示例#4
0
 /**
  * this checks if recalculation of totals and status is needed
  * of the opened invoices
  *
  * @return void
  **/
 private function checkIfUpdateTotals()
 {
     // if the property is not set, we set it here
     if (!PropertyTable::get('last_calculation_date')) {
         PropertyTable::set('last_calculation_date', '1970-01-01');
     }
     $last = new sfDate(PropertyTable::get('last_calculation_date'));
     $today = new sfDate();
     if ($today->diff($last, sfTime::DAY) > 0) {
         CommonTable::calculateTotals();
         PropertyTable::set('last_calculation_date', $today->format('Y-m-d'));
     }
 }
示例#5
0
<?php

include dirname(__FILE__) . '/../../bootstrap/Doctrine.php';
include dirname(__FILE__) . '/../../testTools.php';
$t = new lime_test(2, new lime_output_color());
PropertyTable::set('currency_decimals', 3);
$p = new Payment();
$p->setAmount(2.1215);
$t->is($p->getAmount(), 2.122, 'rounds amount to 3 decimals');
PropertyTable::set('currency_decimals', 2);
$p->setAmount(2.123);
$t->is($p->getAmount(), 2.12, 'rounds amount to 2 decimals');