コード例 #1
0
 /**
  * 
  * @param unknown_type $user_id
  * @param unknown_type $moderator_id
  */
 public function preConfigure($user_id, $moderator_id)
 {
     ParametersConfiguration::setUserPrefix(sfContext::getInstance()->getUser()->getAttribute('login'));
     //Get the user:
     $user = Doctrine::getTable('User')->findOneById($user_id);
     //Get the moderator:
     $moderator = Doctrine::getTable('Moderator')->findOneById($moderator_id);
     //Set the user for the object ImputationAccountTransaction
     $this->getImputation()->setUser($user);
     //If the parameter "follow moderator actions" have been checked: set the moderator for the object ImputationAccountTransaction
     if (ParametersConfiguration::getDefault('default_follow_moderator')) {
         $this->getImputation()->setModerator($moderator);
     } else {
         //Otherwise, set it to null:
         $this->getImputation()->setModeratorId(null);
     }
     //Set the date (today by default):
     $this->getImputation()->setDate(date('m/d/Y H:i'));
     //Set the room, building, method of payment and unity id:
     $this->getImputation()->setRoomId(ImputationDefaultValues::getDefaultValueByType(ImputationDefaultValues::DEFAULT_ROOM, ImputationDefaultValues::ACCOUNT_TRANSACTION_TYPE));
     $this->getImputation()->setBuildingId(ImputationDefaultValues::getDefaultValueByType(ImputationDefaultValues::DEFAULT_BUILDING, ImputationDefaultValues::ACCOUNT_TRANSACTION_TYPE));
     $this->getImputation()->setMethodOfPaymentId(ParametersConfiguration::getDefault('default_method_of_payment'));
     $this->getImputation()->setUnityId(ParametersConfiguration::getDefault('default_currency'));
     //Set the act id to null:
     $this->getImputation()->setActId(null);
     //Set the imputation type to 1:
     $this->getImputation()->setImputationType(ImputationDefaultValues::ACCOUNT_TRANSACTION_TYPE);
 }
コード例 #2
0
 /**
  * 
  * @param integer $user_id
  * @param integer $moderator_id
  * @param integer $act_id
  * @param integer $act_public_category_id
  */
 public function preConfigure($user_id, $moderator_id, $act_id, $act_public_category_id = null)
 {
     ParametersConfiguration::setUserPrefix(sfContext::getInstance()->getUser()->getAttribute('login'));
     //Get the user:
     $user = Doctrine::getTable('User')->findOneById($user_id);
     //Get the moderator:
     $moderator = Doctrine::getTable('Moderator')->findOneById($moderator_id);
     //Get the act:
     //Get the moderator:
     $act = Doctrine::getTable('Act')->findOneById($act_id);
     //Set the user
     $this->getImputation()->setUser($user);
     //If the parameter "follow moderator actions" have been checked: set the moderator for the object ImputationAccountTransaction
     if (ParametersConfiguration::getDefault('default_follow_moderator')) {
         $this->getImputation()->setModerator($moderator);
     } else {
         //Otherwise, set it to null:
         $this->getImputation()->setModeratorId(null);
     }
     //Set the act
     $this->getImputation()->setAct($act);
     //Set the imputation 'total' based on the act_price:
     $act_price = Doctrine::getTable('ActPrice')->findOneByActIdAndActPublicCategoryId($act_id, $act_public_category_id);
     if ($act_price['value'] == -1) {
         $this->getImputation()->setTotal(0);
     } else {
         $this->getImputation()->setTotal($act_price['value']);
     }
     //Set the 'number of unities' by default to 1:
     $this->setNumberOfUnities(1);
     //Set the date (today by default):
     $this->getImputation()->setDate(date('m/d/Y H:i'));
     //Set the end_time (current hour by default):
     $this->setEndTime(date('H:i'));
     //Set the beginning time:
     $this->setBeginningTimeConf($act['duration']);
     //Set the room, building, computer, method of payment and unity id:
     $this->getImputation()->setRoomId(ImputationDefaultValues::getDefaultValueByType(ImputationDefaultValues::DEFAULT_ROOM, ImputationDefaultValues::UNITARY_SERVICE_TYPE));
     $this->getImputation()->setBuildingId(ImputationDefaultValues::getDefaultValueByType(ImputationDefaultValues::DEFAULT_BUILDING, ImputationDefaultValues::UNITARY_SERVICE_TYPE));
     $this->setComputerId(ParametersConfiguration::getDefault('default_computer'));
     $this->getImputation()->setMethodOfPaymentId(ParametersConfiguration::getDefault('default_method_of_payment'));
     $this->getImputation()->setUnityId(ParametersConfiguration::getDefault('default_currency'));
     //Set the imputation type to 2:
     $this->getImputation()->setImputationType(ImputationDefaultValues::UNITARY_SERVICE_TYPE);
 }
コード例 #3
0
 /**
  * 
  * @param integer $user_id
  * @param integer $moderator_id
  * @param integer $act_id
  * @param integer $act_public_category_id
  */
 public function preConfigure($user_id, $moderator_id, $act_id, $act_public_category_id = null)
 {
     ParametersConfiguration::setUserPrefix(sfContext::getInstance()->getUser()->getAttribute('login'));
     //Get the user:
     $user = Doctrine::getTable('User')->findOneById($user_id);
     //Get the moderator:
     $moderator = Doctrine::getTable('Moderator')->findOneById($moderator_id);
     //Get the act:
     //Get the moderator:
     $act = Doctrine::getTable('Act')->findOneById($act_id);
     //Set the user
     $this->getImputation()->setUser($user);
     //If the parameter "follow moderator actions" have been checked: set the moderator for the object ImputationAccountTransaction
     if (ParametersConfiguration::getDefault('default_follow_moderator')) {
         $this->getImputation()->setModerator($moderator);
     } else {
         //Otherwise, set it to null:
         $this->getImputation()->setModeratorId(null);
     }
     //Set the act
     $this->getImputation()->setAct($act);
     //Set the default initial value based on the quantity of the act:
     $this->setInitialValue($this->getImputation()->getAct()->getQuantity());
     //Set the imputation 'total' based on the act_price:
     $act_price = Doctrine::getTable('ActPrice')->findOneByActIdAndActPublicCategoryId($act_id, $act_public_category_id);
     if ($act_price['value'] == -1) {
         if ($this->getImputation()->getAct()->getMonetaryAccount()) {
             $this->getImputation()->setTotal($this->getImputation()->getAct()->getQuantity());
         } else {
             $this->getImputation()->setTotal(0);
         }
     } else {
         $this->getImputation()->setTotal($act_price['value']);
     }
     //Set the date (today by default):
     $this->getImputation()->setDate(date('m/d/Y H:i'));
     //Set the room, building, method of payment and unity id:
     $this->getImputation()->setRoomId(ImputationDefaultValues::getDefaultValueByType(ImputationDefaultValues::DEFAULT_ROOM, ImputationDefaultValues::COUNTABLE_SERVICE_TYPE));
     $this->getImputation()->setBuildingId(ImputationDefaultValues::getDefaultValueByType(ImputationDefaultValues::DEFAULT_BUILDING, ImputationDefaultValues::COUNTABLE_SERVICE_TYPE));
     $this->getImputation()->setMethodOfPaymentId(ParametersConfiguration::getDefault('default_method_of_payment'));
     $this->getImputation()->setUnityId($act->getUnityId());
     //Set the imputation type to 3:
     $this->getImputation()->setImputationType(ImputationDefaultValues::COUNTABLE_SERVICE_TYPE);
 }
コード例 #4
0
?>
"){
				$("#imputation_account_transaction_account_to_pay_id").css("visibility","visible");
			}else{
				$("#imputation_account_transaction_account_to_pay_id").css("visibility","hidden");
			}
			
		});

		$("#imputation_account_transaction_imputation_method_of_payment_id").ready(function(){

			if("<?php 
echo ParametersConfiguration::getDefault('default_method_of_payment');
?>
" == "<?php 
echo ImputationDefaultValues::getAccountMethodId();
?>
"){
				$("#imputation_account_transaction_account_to_pay_id").css("visibility","visible");
			}else{
				$("#imputation_account_transaction_account_to_pay_id").css("visibility","hidden");
			}
			
		});

		$("#imputation_account_transaction_imputation_total").focus(function(){
			changeTotal();
		});

		$("#imputation_account_transaction_sum").change(function(){
			changeTotal();
コード例 #5
0
 /**
  *
  * @param sfWebRequest $request
  * @param ImputationAccountTransactionForm $form
  */
 private function processAccountTransactionForm(sfWebRequest $request, ImputationAccountTransactionForm $form)
 {
     $parameters = $request->getParameter($form->getName());
     if ($parameters['imputation']['account_id'] == 0) {
         $parameters['imputation']['account_id'] = null;
         $this->error_account = true;
     }
     if ($parameters['quantity'] != '') {
         $parameters['sum'] = -$parameters['quantity'];
         $parameters['imputation']['total'] = 0;
         $parameters['imputation']['method_of_payment_id'] = ImputationDefaultValues::getFreeMethodId();
         unset($parameters['unitary_price']);
         unset($parameters['quantity']);
         $this->error_account = false;
     }
     $form->bind($parameters);
     if ($form->isValid()) {
         $transaction = $form->save();
         $account = Doctrine::getTable('Account')->find($parameters['imputation']['account_id']);
         $account->setValue($account->getValue() + $parameters['sum']);
         $account->save();
         if ($parameters['imputation']['method_of_payment_id'] == ImputationDefaultValues::getAccountMethodId()) {
             //If the method of payment is 'account':
             //Find the target account (the account used to pay):
             $target_account = Doctrine::getTable('Account')->find($parameters['account_to_pay_id']);
             $parameters_to_pay = $parameters;
             $parameters_to_pay['sum'] = $parameters['imputation']['total'];
             $parameters_to_pay['imputation']['total'] = $parameters_to_pay['sum'];
             $parameters_to_pay['imputation']['account_id'] = $parameters['account_to_pay_id'];
             $parameters_to_pay['imputation']['unity_id'] = $target_account->getAct()->getUnityId();
             //print_r($parameters_to_pay);exit(-1);
             //Duplicate the form:
             $transaction = new ImputationAccountTransaction();
             $transaction->getImputation()->setUserId($parameters['imputation']['user_id']);
             $form_to_pay = new ImputationAccountTransactionForm($transaction, array('culture' => ParametersConfiguration::getDefault('default_language')));
             //Bind it with the duplicate parameters:
             $form_to_pay->bind($parameters_to_pay);
             if ($form_to_pay->isValid()) {
                 //If the form is valid, change the target account value:
                 $target_account->setValue($target_account->getValue() - $parameters_to_pay['sum']);
                 $target_account->save();
                 //Eventually if the form is valid, save the duplicated form:
                 $form_to_pay->save();
                 $this->error_account = false;
             }
         } else {
             $this->error_account = true;
         }
         $this->redirect('use/index');
     }
 }
コード例 #6
0
 /**
  * 
  * @param sfWebRequest $request
  */
 public function executeBalance(sfWebRequest $request, $xhr = true)
 {
     $this->userCulture = $this->getUser()->getCulture();
     $from = $request->getParameter('from');
     $to = $request->getParameter('to');
     $this->from = $from;
     $this->to = $to;
     $this->xhr = $xhr;
     $this->currency_symbol = ImputationDefaultValues::getDefaultCurrencySymbol();
     $this->positive_accounts = Statistics::getPositiveAccounts();
     $this->negative_accounts = Statistics::getNegativeAccounts();
     $total_accounts['value'] = $this->positive_accounts['value'] + $this->negative_accounts['value'];
     $total_accounts['number'] = $this->positive_accounts['number'] + $this->negative_accounts['number'];
     $this->total_accounts = $total_accounts;
     $this->methods_of_payments_values = Statistics::getTotalValuesByMethodOfPayment($from, $to);
     $this->acts_values = Statistics::getValuesByAct($from, $to);
 }